Commits

Vinay Sajip committed 27c9d85

Removed unused code, added test.

  • Participants
  • Parent commits d9f41ad

Comments (0)

Files changed (2)

File distlib/database.py

                 todo.append(pred)
 
     return req
-
-if __name__ == '__main__':
-    def main():
-        from .database import DistributionPath
-        tempout = StringIO()
-        try:
-            old = sys.stderr
-            sys.stderr = tempout
-            try:
-                d = DistributionPath(include_egg=True)
-                dists = list(d.get_distributions())
-                graph = make_graph(dists)
-            finally:
-                sys.stderr = old
-        except Exception as e:
-            tempout.seek(0)
-            tempout = tempout.read()
-            print('Could not generate the graph')
-            print(tempout)
-            print(e)
-            sys.exit(1)
-
-        for dist, reqs in graph.missing.items():
-            if len(reqs) > 0:
-                print('Warning: Missing dependencies for %r:' % dist.name, \
-                      ', '.join(reqs))
-        # XXX replace with argparse
-        if len(sys.argv) == 1:
-            print('Dependency graph:')
-            print('   %s' % repr(graph).replace('\n', '\n    '))
-            sys.exit(0)
-        elif len(sys.argv) > 1 and sys.argv[1] in ('-d', '--dot'):
-            if len(sys.argv) > 2:
-                filename = sys.argv[2]
-            else:
-                filename = 'depgraph.dot'
-
-            f = open(filename, 'w')
-            try:
-                graph_to_dot(graph, f, True)
-            finally:
-                f.close()
-            tempout.seek(0)
-            tempout = tempout.read()
-            print(tempout)
-            print('Dot file written at %r' % filename)
-            sys.exit(0)
-        else:
-            print('Supported option: -d [filename]')
-            sys.exit(1)
-
-    main()

File tests/test_locators.py

                  ('http://netloc/B', 'http://netloc/A'))
         for url1, url2 in cases:
             self.assertEqual(default_locator.prefer_url(url1, url2), url1)
+
+
+    def test_dist_reqts(self):
+        r = 'config (<=0.3.5)'
+        dist = default_locator.locate(r)
+        self.assertIsNotNone(dist)
+        self.assertTrue(dist.matches_requirement(r))
+        self.assertFalse(dist.matches_requirement('config (0.3.6)'))