def test_find_packages(): def assert_single_chroot(packages, namespace_packages, resources): with yield_chroot(packages, namespace_packages, resources) as chroot: p, n_p, r = SetupPy.find_packages(chroot) assert p == set(packages + namespace_packages) assert n_p == set(namespace_packages) assert r == dict((k, set(v)) for (k, v) in resources.items()) # assert both packages and namespace packages work assert_single_chroot(["foo"], [], {}) assert_single_chroot(["foo"], ["foo"], {}) # assert resources work assert_single_chroot(["foo"], [], {"foo": ["blork.dat"]}) resources = {"foo": ["f0", os.path.join("bar", "baz", "f1"), os.path.join("bar", "baz", "f2")]} assert_single_chroot(["foo"], [], resources) # assert that nearest-submodule is honored with yield_chroot(["foo", "foo.bar"], [], resources) as chroot: _, _, r = SetupPy.find_packages(chroot) assert r == {"foo": {"f0"}, "foo.bar": {os.path.join("baz", "f1"), os.path.join("baz", "f2")}} # assert that nearest submodule splits on module prefixes with yield_chroot(["foo", "foo.bar"], [], {"foo.bar1": ["f0"]}) as chroot: _, _, r = SetupPy.find_packages(chroot) assert r == {"foo": {"bar1/f0"}}
def test_find_packages(): def assert_single_chroot(packages, namespace_packages, resources): with yield_chroot(packages, namespace_packages, resources) as chroot: p, n_p, r = SetupPy.find_packages(chroot) assert p == set(packages + namespace_packages) assert n_p == set(namespace_packages) assert r == dict((k, set(v)) for (k, v) in resources.items()) # assert both packages and namespace packages work assert_single_chroot(['foo'], [], {}) assert_single_chroot(['foo'], ['foo'], {}) # assert resources work assert_single_chroot(['foo'], [], {'foo': ['blork.dat']}) resources = { 'foo': [ 'f0', os.path.join('bar', 'baz', 'f1'), os.path.join('bar', 'baz', 'f2'), ] } assert_single_chroot(['foo'], [], resources) # assert that nearest-submodule is honored with yield_chroot(['foo', 'foo.bar'], [], resources) as chroot: _, _, r = SetupPy.find_packages(chroot) assert r == { 'foo': {'f0'}, 'foo.bar': {os.path.join('baz', 'f1'), os.path.join('baz', 'f2')} } # assert that nearest submodule splits on module prefixes with yield_chroot( ['foo', 'foo.bar'], [], {'foo.bar1': ['f0']}) as chroot: _, _, r = SetupPy.find_packages(chroot) assert r == {'foo': {'bar1/f0'}}
def assert_single_chroot(packages, namespace_packages, resources): with yield_chroot(packages, namespace_packages, resources) as chroot: p, n_p, r = SetupPy.find_packages(chroot) assert p == set(packages + namespace_packages) assert n_p == set(namespace_packages) assert r == dict((k, set(v)) for (k, v) in resources.items())