diff options
| author | Michael Merickel <michael@merickel.org> | 2018-10-14 21:11:41 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2018-10-14 21:11:41 -0500 |
| commit | 3670c2cdb732d378ba6d38e72e7cd875ff726aa9 (patch) | |
| tree | 5213452a778c992d42602efe7d3b3655a349abd5 /tests/test_scripts/test_pdistreport.py | |
| parent | 2b024920847481592b1a13d4006d2a9fa8881d72 (diff) | |
| download | pyramid-3670c2cdb732d378ba6d38e72e7cd875ff726aa9.tar.gz pyramid-3670c2cdb732d378ba6d38e72e7cd875ff726aa9.tar.bz2 pyramid-3670c2cdb732d378ba6d38e72e7cd875ff726aa9.zip | |
move tests out of the package
Diffstat (limited to 'tests/test_scripts/test_pdistreport.py')
| -rw-r--r-- | tests/test_scripts/test_pdistreport.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/test_scripts/test_pdistreport.py b/tests/test_scripts/test_pdistreport.py new file mode 100644 index 000000000..e229667c5 --- /dev/null +++ b/tests/test_scripts/test_pdistreport.py @@ -0,0 +1,73 @@ +import unittest + +class TestPDistReportCommand(unittest.TestCase): + def _callFUT(self, **kw): + argv = [] + from pyramid.scripts.pdistreport import main + return main(argv, **kw) + + def test_no_dists(self): + def platform(): + return 'myplatform' + pkg_resources = DummyPkgResources() + L = [] + def out(*args): + L.extend(args) + result = self._callFUT(pkg_resources=pkg_resources, platform=platform, + out=out) + self.assertEqual(result, None) + self.assertEqual( + L, + ['Pyramid version:', '1', + 'Platform:', 'myplatform', + 'Packages:'] + ) + + def test_with_dists(self): + def platform(): + return 'myplatform' + working_set = (DummyDistribution('abc'), DummyDistribution('def')) + pkg_resources = DummyPkgResources(working_set) + L = [] + def out(*args): + L.extend(args) + result = self._callFUT(pkg_resources=pkg_resources, platform=platform, + out=out) + self.assertEqual(result, None) + self.assertEqual( + L, + ['Pyramid version:', + '1', + 'Platform:', + 'myplatform', + 'Packages:', + ' ', + 'abc', + '1', + ' ', + '/projects/abc', + ' ', + 'def', + '1', + ' ', + '/projects/def'] + ) + +class DummyPkgResources(object): + def __init__(self, working_set=()): + self.working_set = working_set + + def get_distribution(self, name): + return Version('1') + +class Version(object): + def __init__(self, version): + self.version = version + +class DummyDistribution(object): + def __init__(self, name): + self.project_name = name + self.version = '1' + self.location = '/projects/%s' % name + + |
