public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
Date: Sat, 12 May 2012 21:11:51 +0000 (UTC)	[thread overview]
Message-ID: <1336857092.ae95697010a331a98fe112bdac565c3dcbcd3160.zmedico@gentoo> (raw)

commit:     ae95697010a331a98fe112bdac565c3dcbcd3160
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 21:11:32 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 21:11:32 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ae956970

test_digraph: fix bfs for PYTHONHASHSEED=random

---
 pym/portage/tests/util/test_digraph.py |   43 +++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/pym/portage/tests/util/test_digraph.py b/pym/portage/tests/util/test_digraph.py
index b65c0b1..4fb1f95 100644
--- a/pym/portage/tests/util/test_digraph.py
+++ b/pym/portage/tests/util/test_digraph.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -8,6 +8,41 @@ import portage.util
 
 class DigraphTest(TestCase):
 
+	def _assertBFSEqual(self, result, expected):
+		result_stack = list(result)
+		result_stack.reverse()
+		expected_stack = list(reversed(expected))
+		result_compared = []
+		expected_compared = []
+		while result_stack:
+			if not expected_stack:
+				result_compared.append(result_stack.pop())
+				self.assertEqual(result_compared, expected_compared)
+			expected_set = expected_stack.pop()
+			if not isinstance(expected_set, list):
+				expected_set = [expected_set]
+			expected_set = set(expected_set)
+			while expected_set:
+				if not result_stack:
+					expected_compared.extend(expected_set)
+					self.assertEqual(result_compared, expected_compared)
+				obj = result_stack.pop()
+				try:
+					expected_set.remove(obj)
+				except KeyError:
+					expected_compared.extend(expected_set)
+					result_compared.append(obj)
+					self.assertEqual(result_compared, expected_compared)
+				else:
+					expected_compared.append(obj)
+					result_compared.append(obj)
+		if expected_stack:
+			expected_set = expected_stack.pop()
+			if not isinstance(expected_set, list):
+				expected_set = [expected_set]
+			expected_compared.extend(expected_set)
+			self.assertEqual(result_compared, expected_compared)
+
 	def testBackwardCompatibility(self):
 		g = digraph()
 		f = g.copy()
@@ -71,7 +106,7 @@ class DigraphTest(TestCase):
 			self.assertEqual(x.parent_nodes("A", ignore_priority=-2), ["B"])
 			self.assertEqual(x.parent_nodes("A", ignore_priority=-1), [])
 			self.assertEqual(x.hasallzeros(), False)
-			self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "D"), ("D", "C"), ("C", "B")])
+			self._assertBFSEqual(x.bfs("A"), [(None, "A"), ("A", "D"), ("D", "C"), ("C", "B")])
 			self.assertEqual(x.shortest_path("A", "D"), ["A", "D"])
 			self.assertEqual(x.shortest_path("D", "A"), ["D", "C", "B", "A"])
 			self.assertEqual(x.shortest_path("A", "D", ignore_priority=2), None)
@@ -115,7 +150,7 @@ class DigraphTest(TestCase):
 			self.assertEqual(x.parent_nodes("B", ignore_priority=-2), ["A"])
 			self.assertEqual(x.parent_nodes("B", ignore_priority=-1), [])
 			self.assertEqual(x.hasallzeros(), False)
-			self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "C"), ("A", "B"), ("C", "E"), ("C", "D")])
+			self._assertBFSEqual(x.bfs("A"), [(None, "A"), [("A", "C"), ("A", "B")], [("C", "E"), ("C", "D")]])
 			self.assertEqual(x.shortest_path("A", "D"), ["A", "C", "D"])
 			self.assertEqual(x.shortest_path("D", "A"), None)
 			self.assertEqual(x.shortest_path("A", "D", ignore_priority=2), None)
@@ -158,7 +193,7 @@ class DigraphTest(TestCase):
 			self.assertEqual(x.parent_nodes("A", ignore_priority=0), ["C"])
 			self.assertEqual(x.parent_nodes("A", ignore_priority=1), [])
 			self.assertEqual(x.hasallzeros(), False)
-			self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "C"), ("A", "B")])
+			self._assertBFSEqual(x.bfs("A"), [(None, "A"), [("A", "C"), ("A", "B")]])
 			self.assertEqual(x.shortest_path("A", "C"), ["A", "C"])
 			self.assertEqual(x.shortest_path("C", "A"), ["C", "A"])
 			self.assertEqual(x.shortest_path("A", "C", ignore_priority=0), ["A", "B", "C"])



             reply	other threads:[~2012-05-12 21:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-12 21:11 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-03-13 21:46 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/ Michał Górny
2014-02-02  4:11 Arfrever Frehtes Taifersar Arahesis
2014-01-26  4:06 Arfrever Frehtes Taifersar Arahesis
2013-05-18 23:53 Zac Medico
2012-05-12 19:30 Zac Medico
2012-05-12 19:27 Zac Medico
2012-04-03 16:06 Zac Medico
2011-12-02  2:07 Zac Medico
2011-10-05  3:22 Zac Medico
2011-07-01  8:50 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336857092.ae95697010a331a98fe112bdac565c3dcbcd3160.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox