def test_read_exports(self): d = DistributionPath().get_distribution('babar') r = d.exports self.assertIn('foo', r) d = r['foo'] self.assertIn('bar', d) self.check_entry(d['bar'], 'bar', 'baz', 'barbaz', ['a=10', 'b']) self.assertIn('bar.baz', r) d = r['bar.baz'] self.assertIn('foofoo', d) self.check_entry(d['foofoo'], 'foofoo', 'baz.foo', 'bazbar', []) self.assertIn('real', d) e = d['real'] self.check_entry(e, 'real', 'cgi', 'print_directory', []) import cgi self.assertIs(e.value, cgi.print_directory) # See issue #78. Test reading an entry_points.txt with leading spaces TEST_EXPORTS = b""" [paste.server_runner] main = waitress:serve_paste [console_scripts] waitress-serve = waitress.runner:run """ with io.BytesIO(TEST_EXPORTS) as f: exports = read_exports(f) self.assertEqual(set(exports.keys()), set(['paste.server_runner', 'console_scripts']))
def test_read_exports(self): d = DistributionPath().get_distribution("babar") r = d.exports self.assertIn("foo", r) d = r["foo"] self.assertIn("bar", d) self.check_entry(d["bar"], "bar", "baz", "barbaz", ["a=10", "b"]) self.assertIn("bar.baz", r) d = r["bar.baz"] self.assertIn("foofoo", d) self.check_entry(d["foofoo"], "foofoo", "baz.foo", "bazbar", []) self.assertIn("real", d) e = d["real"] self.check_entry(e, "real", "cgi", "print_directory", []) import cgi self.assertIs(e.value, cgi.print_directory) # See issue #78. Test reading an entry_points.txt with leading spaces TEST_EXPORTS = b""" [paste.server_runner] main = waitress:serve_paste [console_scripts] waitress-serve = waitress.runner:run """ with io.BytesIO(TEST_EXPORTS) as f: exports = read_exports(f) self.assertEqual(set(exports.keys()), set(["paste.server_runner", "console_scripts"]))
def test_write_exports(self): exports = { 'foo': { 'v1': ExportEntry('v1', 'p1', 's1', []), 'v2': ExportEntry('v2', 'p2', 's2', ['f2=a', 'g2']), }, 'bar': { 'v3': ExportEntry('v3', 'p3', 's3', ['f3', 'g3=h']), 'v4': ExportEntry('v4', 'p4', 's4', ['f4', 'g4']), }, } fd, fn = tempfile.mkstemp() try: os.close(fd) with open(fn, 'wb') as f: write_exports(exports, f) with open(fn, 'rb') as f: actual = read_exports(f) self.assertEqual(actual, exports) finally: os.remove(fn)