From c54b7eaca3f9d68ade36cf82201083947086c966 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Thu, 6 Nov 2014 19:13:56 +0000 Subject: Make test_less_than test reverse --- exts/pip_find_deps_tests.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/exts/pip_find_deps_tests.py b/exts/pip_find_deps_tests.py index 83fe4b1..b838714 100755 --- a/exts/pip_find_deps_tests.py +++ b/exts/pip_find_deps_tests.py @@ -46,19 +46,28 @@ class ConflictDetectionTests(unittest.TestCase): ('==', parse_version('0.2')))]) def test_less_than(self): - # ('==', '0.1') conflicts with ('<', 0.1) - requirements = parse_requirements(['a == 0.1', 'a < 0.1']) - # TODO: and the reverse + def run(requirements, expected_conflicts): + deps = pip_find_deps.resolve_version_constraints(requirements) - deps = pip_find_deps.resolve_version_constraints(requirements) + self.assertEqual(len(deps), 1) - self.assertEqual(len(deps), 1) + _, dep = deps.popitem() - _, dep = deps.popitem() + self.assertEqual(len(dep.conflicts), 1) + self.assertEqual(dep.conflicts, expected_conflicts) - self.assertEqual(len(dep.conflicts), 1) - self.assertEqual(dep.conflicts, [(('==', parse_version('0.1')), - ('<', parse_version('0.1')))]) + def reverse(xs): + return xs[::-1] + + requirements = list(parse_requirements(['a == 0.1', 'a < 0.1'])) + expected_conflicts = [(('==', parse_version('0.1')), + ('<', parse_version('0.1')))] + + # ('==', '0.1') conflicts with ('<', 0.1) + run(requirements, expected_conflicts) + + # ('<', 0.1) conflicts with ('==', '0.1') + run(reverse(requirements), reverse(expected_conflicts)) if __name__ == '__main__': -- cgit v1.2.1