def test_prereleases(self): locator = AggregatingLocator( JSONLocator(), SimpleScrapingLocator("https://pypi.python.org/simple/", timeout=3.0), scheme="legacy" ) REQT = "SQLAlchemy (>0.5.8, < 0.6)" finder = DependencyFinder(locator) d = locator.locate(REQT) self.assertIsNone(d) d = locator.locate(REQT, True) self.assertIsNotNone(d) self.assertEqual(d.name_and_version, "SQLAlchemy (0.6beta3)") dist = make_dist("dummy", "0.1") dist.metadata.run_requires = [{"requires": [REQT]}] dists, problems = finder.find(dist, prereleases=True) self.assertFalse(problems) actual = sorted(dists, key=lambda o: o.name_and_version) self.assertEqual(actual[0].name_and_version, "SQLAlchemy (0.6beta3)") dists, problems = finder.find(dist) # Test changed since now prereleases as found as a last resort. # self.assertEqual(dists, set([dist])) # self.assertEqual(len(problems), 1) # problem = problems.pop() # self.assertEqual(problem, ('unsatisfied', REQT)) self.assertEqual(dists, set([actual[0], dist])) self.assertFalse(problems)
def test_dependency_finder(self): locator = AggregatingLocator( JSONLocator(), SimpleScrapingLocator('https://pypi.python.org/simple/', timeout=3.0), scheme='legacy') finder = DependencyFinder(locator) dists, problems = finder.find('irc (== 5.0.1)') self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, ['hgtools', 'irc', 'pytest-runner']) dists, problems = finder.find('irc (== 5.0.1)', meta_extras=[':test:']) self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, ['hgtools', 'irc', 'py', 'pytest', 'pytest-runner']) g = make_graph(dists) slist, cycle = g.topological_sort() self.assertFalse(cycle) names = [d.name for d in slist] expected = set([ ('hgtools', 'py', 'pytest', 'pytest-runner', 'irc'), ('py', 'hgtools', 'pytest', 'pytest-runner', 'irc'), ('hgtools', 'py', 'pytest-runner', 'pytest', 'irc'), ('py', 'hgtools', 'pytest-runner', 'pytest', 'irc') ]) self.assertIn(tuple(names), expected) # Test with extras dists, problems = finder.find('Jinja2 (== 2.6)') self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual, ['Jinja2 (2.6)']) dists, problems = finder.find('Jinja2 [i18n] (== 2.6)') self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual[-2], 'Jinja2 (2.6)') self.assertTrue(actual[-1].startswith('pytz (')) self.assertTrue(actual[0].startswith('Babel (')) actual = [d.build_time_dependency for d in dists] self.assertEqual(actual, [False, False, False]) # Now test with extra in dependency locator.clear_cache() dummy = make_dist('dummy', '0.1') dummy.metadata.run_requires = [{'requires': ['Jinja2 [i18n]']}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith('Babel (')) locator.clear_cache() dummy.metadata.run_requires = [{'requires': ['Jinja2']}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith('Jinja2 ('))
def test_prereleases(self): locator = AggregatingLocator(JSONLocator(), SimpleScrapingLocator( 'https://pypi.python.org/simple/', timeout=3.0), scheme='legacy') REQT = 'SQLAlchemy (>0.5.8, < 0.6)' finder = DependencyFinder(locator) d = locator.locate(REQT) self.assertIsNone(d) d = locator.locate(REQT, True) self.assertIsNotNone(d) self.assertEqual(d.name_and_version, 'SQLAlchemy (0.6beta3)') dist = make_dist('dummy', '0.1') dist.metadata.run_requires = [{'requires': [REQT]}] dists, problems = finder.find(dist, prereleases=True) self.assertFalse(problems) actual = sorted(dists, key=lambda o: o.name_and_version) self.assertEqual(actual[0].name_and_version, 'SQLAlchemy (0.6beta3)') dists, problems = finder.find(dist) # Test changed since now prereleases as found as a last resort. #self.assertEqual(dists, set([dist])) #self.assertEqual(len(problems), 1) #problem = problems.pop() #self.assertEqual(problem, ('unsatisfied', REQT)) self.assertEqual(dists, set([actual[0], dist])) self.assertFalse(problems)
def test_prereleases(self): locator = AggregatingLocator( JSONLocator(), SimpleScrapingLocator('https://pypi.python.org/simple/', timeout=3.0), scheme='legacy') REQT = 'SQLAlchemy (>0.5.8, < 0.6)' finder = DependencyFinder(locator) d = locate(REQT) self.assertIsNone(d) d = locate(REQT, True) self.assertIsNotNone(d) self.assertEqual(d.name_and_version, 'SQLAlchemy (0.6beta3)') dist = make_dist('dummy', '0.1') dist.metadata['Requires-Dist'] = [REQT] dists, problems = finder.find(dist, prereleases=True) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual[0], 'SQLAlchemy (0.6beta3)') dists, problems = finder.find(dist) self.assertEqual(dists, set([dist])) self.assertEqual(len(problems), 1) problem = problems.pop() self.assertEqual(problem, ('unsatisfied', REQT))
def test_dependency_finder(self): locator = AggregatingLocator( JSONLocator(), SimpleScrapingLocator("https://pypi.python.org/simple/", timeout=3.0), scheme="legacy" ) finder = DependencyFinder(locator) dists, problems = finder.find("irc (== 5.0.1)") self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, ["hgtools", "irc", "pytest-runner", "setuptools_scm"]) dists, problems = finder.find("irc (== 5.0.1)", meta_extras=[":test:"]) self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, ["hgtools", "irc", "py", "pytest", "pytest-runner", "setuptools_scm"]) g = make_graph(dists) slist, cycle = g.topological_sort() self.assertFalse(cycle) names = [d.name for d in slist] expected = set( [ ("setuptools_scm", "hgtools", "py", "pytest-runner", "pytest", "irc"), ("setuptools_scm", "hgtools", "py", "pytest", "pytest-runner", "irc"), ("setuptools_scm", "py", "hgtools", "pytest-runner", "pytest", "irc"), ("hgtools", "setuptools_scm", "py", "pytest", "pytest-runner", "irc"), ("py", "hgtools", "setuptools_scm", "pytest", "pytest-runner", "irc"), ("hgtools", "setuptools_scm", "py", "pytest-runner", "pytest", "irc"), ("py", "hgtools", "setuptools_scm", "pytest-runner", "pytest", "irc"), ("py", "setuptools_scm", "hgtools", "pytest", "pytest-runner", "irc"), ("pytest", "setuptools_scm", "hgtools", "pytest-runner", "irc"), ("hgtools", "setuptools_scm", "pytest", "pytest-runner", "irc"), ("py", "setuptools_scm", "hgtools", "pytest-runner", "pytest", "irc"), ("py", "setuptools_scm", "pytest", "pytest-runner", "hgtools", "irc"), ("py", "setuptools_scm", "pytest-runner", "pytest", "hgtools", "irc"), ("py", "setuptools_scm", "pytest", "hgtools", "pytest-runner", "irc"), ("setuptools_scm", "py", "pytest", "hgtools", "pytest-runner", "irc"), ("setuptools_scm", "py", "pytest-runner", "hgtools", "pytest", "irc"), ("py", "setuptools_scm", "pytest-runner", "hgtools", "pytest", "irc"), ("setuptools_scm", "py", "pytest", "pytest-runner", "hgtools", "irc"), ] ) self.assertIn(tuple(names), expected) # Test with extras dists, problems = finder.find("Jinja2 (== 2.6)") self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual, ["Jinja2 (2.6)"]) dists, problems = finder.find("Jinja2 [i18n] (== 2.6)") self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual[-2], "Jinja2 (2.6)") self.assertTrue(actual[-1].startswith("pytz (")) self.assertTrue(actual[0].startswith("Babel (")) actual = [d.build_time_dependency for d in dists] self.assertEqual(actual, [False, False, False]) # Now test with extra in dependency locator.clear_cache() dummy = make_dist("dummy", "0.1") dummy.metadata.run_requires = [{"requires": ["Jinja2 [i18n]"]}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith("Babel (")) locator.clear_cache() dummy.metadata.run_requires = [{"requires": ["Jinja2"]}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith("Jinja2 ("))
def test_dependency_finder(self): locator = AggregatingLocator(JSONLocator(), SimpleScrapingLocator( 'https://pypi.python.org/simple/', timeout=3.0), scheme='legacy') finder = DependencyFinder(locator) dists, problems = finder.find('irc (== 5.0.1)') self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, ['hgtools', 'irc', 'pytest-runner', 'setuptools_scm']) dists, problems = finder.find('irc (== 5.0.1)', meta_extras=[':test:']) self.assertFalse(problems) actual = sorted([d.name for d in dists]) self.assertEqual(actual, [ 'hgtools', 'irc', 'py', 'pytest', 'pytest-runner', 'setuptools_scm' ]) g = make_graph(dists) slist, cycle = g.topological_sort() self.assertFalse(cycle) names = [d.name for d in slist] expected = set([ ('setuptools_scm', 'hgtools', 'py', 'pytest-runner', 'pytest', 'irc'), ('setuptools_scm', 'hgtools', 'py', 'pytest', 'pytest-runner', 'irc'), ('setuptools_scm', 'py', 'hgtools', 'pytest-runner', 'pytest', 'irc'), ('hgtools', 'setuptools_scm', 'py', 'pytest', 'pytest-runner', 'irc'), ('py', 'hgtools', 'setuptools_scm', 'pytest', 'pytest-runner', 'irc'), ('hgtools', 'setuptools_scm', 'py', 'pytest-runner', 'pytest', 'irc'), ('py', 'hgtools', 'setuptools_scm', 'pytest-runner', 'pytest', 'irc'), ('py', 'setuptools_scm', 'hgtools', 'pytest', 'pytest-runner', 'irc'), ('pytest', 'setuptools_scm', 'hgtools', 'pytest-runner', 'irc'), ('hgtools', 'setuptools_scm', 'pytest', 'pytest-runner', 'irc'), ('py', 'setuptools_scm', 'hgtools', 'pytest-runner', 'pytest', 'irc'), ('py', 'setuptools_scm', 'pytest', 'pytest-runner', 'hgtools', 'irc'), ('py', 'setuptools_scm', 'pytest-runner', 'pytest', 'hgtools', 'irc'), ('py', 'setuptools_scm', 'pytest', 'hgtools', 'pytest-runner', 'irc'), ('setuptools_scm', 'py', 'pytest', 'hgtools', 'pytest-runner', 'irc'), ('setuptools_scm', 'py', 'pytest-runner', 'hgtools', 'pytest', 'irc'), ('py', 'setuptools_scm', 'pytest-runner', 'hgtools', 'pytest', 'irc'), ('setuptools_scm', 'py', 'pytest', 'pytest-runner', 'hgtools', 'irc'), ]) self.assertIn(tuple(names), expected) # Test with extras dists, problems = finder.find('Jinja2 (== 2.6)') self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual, ['Jinja2 (2.6)']) dists, problems = finder.find('Jinja2 [i18n] (== 2.6)') self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertEqual(actual[-2], 'Jinja2 (2.6)') self.assertTrue(actual[-1].startswith('pytz (')) self.assertTrue(actual[0].startswith('Babel (')) actual = [d.build_time_dependency for d in dists] self.assertEqual(actual, [False, False, False]) # Now test with extra in dependency locator.clear_cache() dummy = make_dist('dummy', '0.1') dummy.metadata.run_requires = [{'requires': ['Jinja2 [i18n]']}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith('Babel (')) locator.clear_cache() dummy.metadata.run_requires = [{'requires': ['Jinja2']}] dists, problems = finder.find(dummy) self.assertFalse(problems) actual = sorted([d.name_and_version for d in dists]) self.assertTrue(actual[0].startswith('Jinja2 ('))