Python pkg_resources.WorkingSet() Examples
The following are 30
code examples of pkg_resources.WorkingSet().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pkg_resources
, or try the search function
.
Example #1
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_spec_debugged_via_cmdline(self): stub_stdouts(self) stub_item_attr_value( self, mocks, 'dummy', runtime.ToolchainRuntime(toolchain.NullToolchain()), ) working_set = mocks.WorkingSet({ 'calmjs.runtime': [ 'tool = calmjs.testing.mocks:dummy', ], }) rt = runtime.Runtime(working_set=working_set, prog='calmjs') with pretty_logging(logger='calmjs', stream=mocks.StringIO()) as s: result = rt(['tool', '--export-target', 'dummy', '-d']) self.assertEqual(result['debug'], 1) # also test for the export_target resolution self.assertIn( "'export_target' resolved to '%s'" % join(self.cwd, 'dummy'), s.getvalue())
Example #2
Source File: test_artifact.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_iter_builders_side_effect(self): # inject dummy module and add cleanup mod = ModuleType('calmjs_testing_dummy') mod.complete = generic_builder self.addCleanup(sys.modules.pop, 'calmjs_testing_dummy') sys.modules['calmjs_testing_dummy'] = mod working_dir = utils.mkdtemp(self) utils.make_dummy_dist(self, ( ('entry_points.txt', '\n'.join([ '[calmjs.artifacts]', 'artifact.js = calmjs_testing_dummy:complete', ])), ), 'app', '1.0', working_dir=working_dir) mock_ws = WorkingSet([working_dir]) registry = ArtifactRegistry('calmjs.artifacts', _working_set=mock_ws) registry.update_artifact_metadata('app', {}) root = join(working_dir, 'app-1.0.egg-info', 'calmjs_artifacts') self.assertFalse(exists(root)) ep, toolchain, spec = next(registry.iter_builders_for('app')) self.assertFalse(exists(root)) # directory only created after the toolchain is executed toolchain(spec) self.assertTrue(exists(root))
Example #3
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 6 votes |
def tests_flatten_egginfo_json_missing_deps(self): """ Missing dependencies should not cause a hard failure. """ make_dummy_dist(self, ( ('requires.txt', '\n'.join([ 'uilib>=1.0', ])), ), 'app', '2.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) # Python dependency acquisition failures should fail hard. with self.assertRaises(pkg_resources.DistributionNotFound): calmjs_dist.flatten_egginfo_json(['app'], working_set=working_set)
Example #4
Source File: test_artifact.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_denormalized_package_names(self): working_dir = utils.mkdtemp(self) utils.make_dummy_dist(self, ( ('entry_points.txt', '\n'.join([ '[calmjs.artifacts]', 'full.js = calmjs_testbuild:full', ])), ), 'de_normal_name', '1.0', working_dir=working_dir) mock_ws = WorkingSet([working_dir]) # stub the default working set in calmjs.dist for the resolver # to work. utils.stub_item_attr_value(self, dist, 'default_working_set', mock_ws) # still specify the working set. registry = ArtifactRegistry('calmjs.artifacts', _working_set=mock_ws) self.assertEqual( 1, len(list(registry.iter_records_for('de_normal_name')))) # also test internal consistency self.assertIn('de_normal_name', registry.compat_builders['full']) self.assertIn('de_normal_name', registry.packages) default = registry.get_artifact_filename('de_normal_name', 'full.js') normal = registry.get_artifact_filename( safe_name('de_normal_name'), 'full.js') self.assertEqual(default, normal)
Example #5
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_runtime_main_with_broken_runtime(self): stub_stdouts(self) working_set = mocks.WorkingSet({'calmjs.runtime': [ 'broken = calmjs.tests.test_runtime:broken', ]}) with self.assertRaises(SystemExit): runtime.main( ['-vvd', '-h'], runtime_cls=lambda: runtime.Runtime(working_set=working_set) ) out = sys.stdout.getvalue() err = sys.stderr.getvalue() self.assertIn('broken', err) self.assertIn('Traceback', err) self.assertIn('a fake import error', err) self.assertNotIn('broken', out)
Example #6
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_get_record_key_normalised(self): make_dummy_dist(self, (( 'entry_points.txt', '[calmjs.toolchain.advice.apply]\n' 'example = example.advice[extra]\n' ),), 'example_namespace_package', '1.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) reg = AdviceApplyRegistry( CALMJS_TOOLCHAIN_ADVICE + CALMJS_TOOLCHAIN_ADVICE_APPLY_SUFFIX, _working_set=working_set ) # key will be normalized record = reg.get_record('example-namespace-package') self.assertEqual(1, len(record)) self.assertEqual( pkg_resources.Requirement.parse('example.advice[extra]'), record[0], )
Example #7
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_runtime_group_not_runtime_reported(self): stub_stdouts(self) make_dummy_dist(self, (( 'entry_points.txt', '[calmjs.runtime]\n' 'bs = calmjs.testing.module3.runtime:fake_bootstrap\n' ),), 'example.package', '1.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) with self.assertRaises(SystemExit): runtime.main( ['-h'], runtime_cls=lambda: runtime.Runtime(working_set=working_set) ) self.assertIn( "'calmjs.runtime' entry point " "'bs = calmjs.testing.module3.runtime:fake_bootstrap' from " "'example.package 1.0' invalid for instance of " "'calmjs.runtime.Runtime': target not an instance of " "'calmjs.runtime.BaseRuntime' or its subclass; not registering " "invalid entry point", sys.stderr.getvalue() )
Example #8
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_standard_toolchain_process(self): make_dummy_dist(self, (( 'entry_points.txt', '[calmjs.toolchain.advice]\n' 'calmjs.toolchain:Toolchain = calmjs.tests.test_toolchain:dummy\n' ),), 'example.package', '1.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) reg = AdviceRegistry(CALMJS_TOOLCHAIN_ADVICE, _working_set=working_set) toolchain = Toolchain() spec = Spec() with pretty_logging(stream=StringIO()) as s: reg.process_toolchain_spec_package( toolchain, spec, 'example.package') self.assertEqual(spec['dummy'], ['dummy']) self.assertIn( "found advice setup steps registered for package/requirement " "'example.package'; checking for compatibility with toolchain " "'calmjs.toolchain:Toolchain'", s.getvalue(), )
Example #9
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_subparser_level_2_missing_argument(self): stub_stdouts(self) working_set = mocks.WorkingSet({ 'calmjs.runtime': [ 'artifact = calmjs.runtime:artifact', ], 'calmjs.runtime.artifact': [ 'build = calmjs.runtime:artifact_build', ], }) rt = runtime.Runtime(working_set=working_set, prog='calmjs') # An underspecified command should also return False. with self.assertRaises(SystemExit): rt(['artifact', 'build']) # ensure the help for the command itself is printed self.assertIn('calmjs artifact build: error', sys.stderr.getvalue())
Example #10
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_subparser_level_2_unrecognized_argument_final(self): stub_stdouts(self) working_set = mocks.WorkingSet({ 'calmjs.runtime': [ 'artifact = calmjs.runtime:artifact', ], 'calmjs.runtime.artifact': [ 'build = calmjs.runtime:artifact_build', ], }) rt = runtime.Runtime(working_set=working_set, prog='calmjs') # An underspecified command should also return False. with self.assertRaises(SystemExit): rt(['artifact', 'build', 'package', '--no-such-argument']) # ensure the help for the command itself is printed self.assertIn('calmjs artifact build: error', sys.stderr.getvalue())
Example #11
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_subparsers_unrecognized_argument_interspersed(self): working_set = mocks.WorkingSet({ 'calmjs.runtime': [ 'broken = calmjs.tests.test_runtime:default_cmd', ], }) rt = runtime.Runtime(working_set=working_set, prog='calmjs') # An underspecified command should also return False. with self.assertRaises(SystemExit): rt(['--1', 'broken', '--2', 'dummy', '--3']) # ensure the help for the command itself is printed err = sys.stderr.getvalue() self.assertIn( 'calmjs: error: unrecognized arguments: --1', err) self.assertIn( 'calmjs broken: error: unrecognized arguments: --2', err) self.assertIn( 'calmjs broken dummy: error: unrecognized arguments: --3', err)
Example #12
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_resolve_and_order(self): fake = LoaderPluginRegistry('fake_registry', _working_set=WorkingSet({ 'fake_registry': [ 'foo = calmjs.tests.test_toolchain:MockLPHandler']})) registries = {'fake_registry': fake} stub_item_attr_value( self, calmjs_toolchain, 'get_registry', registries.get) spec = {'calmjs_loaderplugin_registry_name': 'fake_registry'} with pretty_logging(stream=StringIO()) as s: registry = spec_update_loaderplugin_registry(spec) self.assertIn( "using loaderplugin registry 'fake_registry'", s.getvalue()) self.assertIs(registry, fake) spec = { 'calmjs_loaderplugin_registry_name': 'fake_registry', 'calmjs_loaderplugin_registry': BaseLoaderPluginRegistry('raw'), }
Example #13
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_wrong_registry_type(self): advice = AdviceRegistry('adv', _working_set=WorkingSet({})) registries = {'adv': advice} stub_item_attr_value( self, calmjs_toolchain, 'get_registry', registries.get) spec = {'calmjs_loaderplugin_registry_name': 'adv'} with pretty_logging(stream=StringIO()) as s: registry = spec_update_loaderplugin_registry(spec) self.assertIn( "object referenced in spec is not a valid", s.getvalue()) self.assertIsNot(registry, advice) self.assertTrue(isinstance(registry, BaseLoaderPluginRegistry)) spec = {} with pretty_logging(stream=StringIO()) as s: registry = spec_update_loaderplugin_registry(spec, default='adv') self.assertIn( "provided default is not a valid loaderplugin registry", s.getvalue()) self.assertIsNot(registry, advice) self.assertTrue(isinstance(registry, BaseLoaderPluginRegistry))
Example #14
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_simple_record(self): working_set = mocks.WorkingSet({__name__: [ 'dummy/whatever/module.js = module', 'dummy/whatever/module-slim.js = module', ]}, dist=Distribution(project_name='calmjs.testing')) registry = base.BaseExternalModuleRegistry( __name__, _working_set=working_set) self.assertEqual(len(registry.raw_entry_points), 2) self.assertEqual(registry.get_record('module'), { 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', }) self.assertEqual(list(registry.iter_records()), [('module', { 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', })]) self.assertEqual(registry.get_records_for_package('calmjs.testing'), [ 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', ])
Example #15
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_toolchain_spec_prepare_loaderplugins_missing(self): reg = LoaderPluginRegistry('simple', _working_set=WorkingSet({ 'simple': [ 'foo = calmjs.tests.test_toolchain:MockLPHandler', 'bar = calmjs.tests.test_toolchain:MockLPHandler', ], })) spec = Spec( calmjs_loaderplugin_registry=reg, loaderplugin_sourcepath_maps={ 'foo': {'foo!thing': 'thing'}, 'missing': {'missing!thing': 'thing'}, 'bar': {'bar!thing': 'thing'}, }, ) with pretty_logging(stream=StringIO()) as s: toolchain_spec_prepare_loaderplugins( self.toolchain, spec, 'loaderplugin', 'loaders') self.assertEqual({ 'foo!thing': 'thing', 'bar!thing': 'thing', }, spec['loaderplugin_sourcepath']) self.assertEqual({ 'foo': 'foo', 'bar': 'bar', }, spec['loaders']) self.assertIn( "loaderplugin handler for 'missing' not found in loaderplugin " "registry 'simple'", s.getvalue()) self.assertIn( "will not be compiled into the build target: ['missing!thing']", s.getvalue())
Example #16
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_toolchain_compile_loaderplugin_entry_registered(self): """ A rough standalone test for handling of loader plugins. """ reg = LoaderPluginRegistry('simple', _working_set=WorkingSet({ 'simple': [ 'foo = calmjs.tests.test_toolchain:MockLPHandler', 'bar = calmjs.tests.test_toolchain:MockLPHandler', ], })) src_dir = mkdtemp(self) src = join(src_dir, 'target.txt') spec = Spec(calmjs_loaderplugin_registry=reg) with pretty_logging(stream=StringIO()) as s: bar_results = self.toolchain.compile_loaderplugin_entry(spec, ( 'bar!target.txt', src, 'bar!target.txt', 'bar!target.txt')) foo_results = self.toolchain.compile_loaderplugin_entry(spec, ( 'foo!target.txt', src, 'foo!target.txt', 'foo!target.txt')) self.assertEqual('', s.getvalue()) self.assertEqual(( {'foo!target.txt': 'foo!target.txt'}, {'foo!target.txt': 'foo!target.txt'}, ['foo!target.txt'], ), foo_results) self.assertEqual(( {'bar!target.txt': 'bar!target.txt'}, {'bar!target.txt': 'bar!target.txt'}, ['bar!target.txt'], ), bar_results) # recursive lookups are generally not needed, if the target # supplied _is_ the target.
Example #17
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_standard_toolchain_process_nothing(self): working_set = pkg_resources.WorkingSet([]) reg = AdviceRegistry(CALMJS_TOOLCHAIN_ADVICE, _working_set=working_set) toolchain = Toolchain() spec = Spec() with pretty_logging(stream=StringIO()) as s: reg.process_toolchain_spec_package(toolchain, spec, 'calmjs') self.assertIn( "no advice setup steps registered for package/requirement " "'calmjs'", s.getvalue(), )
Example #18
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_not_toolchain_process(self): working_set = pkg_resources.WorkingSet([]) reg = AdviceRegistry(CALMJS_TOOLCHAIN_ADVICE, _working_set=working_set) with pretty_logging(stream=StringIO()) as s: self.assertIsNone( reg.process_toolchain_spec_package(object(), Spec(), 'calmjs')) self.assertIn( "apply_toolchain_spec or process_toolchain_spec_package must be " "invoked with a toolchain instance, not <object", s.getvalue(), )
Example #19
Source File: test_toolchain.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_get_package_advices(self): make_dummy_dist(self, (( 'entry_points.txt', '[calmjs.toolchain.advice]\n' 'calmjs.toolchain:Toolchain = calmjs.tests.test_toolchain:dummy\n' 'calmjs.toolchain:Alt = calmjs.tests.test_toolchain:dummy\n' ),), 'example.package', '1.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) reg = AdviceRegistry(CALMJS_TOOLCHAIN_ADVICE, _working_set=working_set) self.assertEqual(sorted(reg.get('example.package').keys()), [ 'calmjs.toolchain:Alt', 'calmjs.toolchain:Toolchain', ])
Example #20
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 5 votes |
def tests_flatten_egginfo_json_nulled(self): """ Need to ensure the *correct* version is picked. """ lib = make_dummy_dist(self, ( # noqa: F841 ('requires.txt', '\n'.join([])), (self.pkgname, json.dumps({ 'dependencies': { 'jquery': '~3.0.0', 'left-pad': '1.1.1', }, })), ), 'lib', '1.0.0') app = make_dummy_dist(self, ( # noqa: F841 ('requires.txt', '\n'.join([ 'lib>=1.0.0', ])), (self.pkgname, json.dumps({ 'dependencies': { 'jquery': '~3.0.0', 'left-pad': None, }, })), ), 'app', '2.0') working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir]) answer = { 'dependencies': { 'jquery': '~3.0.0', # left-pad will be absent as app removed via None. }, 'devDependencies': {}, } result = calmjs_dist.flatten_egginfo_json( ['app'], working_set=working_set) self.assertEqual(result, answer)
Example #21
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_module_module_registry_names_no_reg(self): working_set = pkg_resources.WorkingSet() self.assertEqual(calmjs_dist.flatten_module_registry_names( ['nothing'], working_set=working_set), []) self.assertEqual(calmjs_dist.get_module_registry_names( ['nothing'], working_set=working_set), [])
Example #22
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_module_module_registry_names_success(self): base = make_dummy_dist(self, ( ('requires.txt', ''), ), 'base', '1.0.0') lib = make_dummy_dist(self, ( ('requires.txt', 'base>=1.0.0'), (calmjs_dist.CALMJS_MODULE_REGISTRY_TXT, '\n'.join(['reg1', 'reg2'])), ), 'lib', '1.0.0') app = make_dummy_dist(self, ( ('requires.txt', 'lib>=1.0.0'), (calmjs_dist.CALMJS_MODULE_REGISTRY_TXT, '\n'.join(['reg2', 'reg3'])), ), 'app', '2.0') working_set = pkg_resources.WorkingSet() working_set.add(base, self._calmjs_testing_tmpdir) working_set.add(lib, self._calmjs_testing_tmpdir) working_set.add(app, self._calmjs_testing_tmpdir) self.assertEqual(calmjs_dist.get_module_registry_names( ['base'], working_set=working_set), []) self.assertEqual(calmjs_dist.get_module_registry_names( ['lib'], working_set=working_set), ['reg1', 'reg2']) self.assertEqual(calmjs_dist.get_module_registry_names( ['app'], working_set=working_set), ['reg2', 'reg3']) self.assertEqual(calmjs_dist.get_module_registry_names( ['nothing'], working_set=working_set), []) self.assertEqual(calmjs_dist.flatten_module_registry_names( ['base'], working_set=working_set), []) self.assertEqual(calmjs_dist.flatten_module_registry_names( ['lib'], working_set=working_set), ['reg1', 'reg2']) self.assertEqual(calmjs_dist.flatten_module_registry_names( ['app'], working_set=working_set), ['reg1', 'reg2', 'reg3']) self.assertEqual(calmjs_dist.flatten_module_registry_names( ['nothing'], working_set=working_set), [])
Example #23
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_calmjs_artifact_declarations(self): from calmjs.registry import _inst # the actual implementations this is supporting from calmjs.artifact import build_calmjs_artifacts from calmjs.artifact import ArtifactRegistry working_dir = mkdtemp(self) make_dummy_dist(self, ( ('entry_points.txt', '\n'.join([ '[calmjs.registry]', 'calmjs.artifacts = calmjs.artifact:ArtifactsRegistry', ])), ), 'calmjs', '1.0', working_dir=working_dir) make_dummy_dist(self, ( ('entry_points.txt', '\n'.join([ '[calmjs.artifacts]', 'example.js = example:builder', ])), ), 'some.package', '1.0', working_dir=working_dir) mock_ws = pkg_resources.WorkingSet([working_dir]) registry_id = 'calmjs.artifacts' registry = ArtifactRegistry(registry_id, _working_set=mock_ws) # cleanup the about to be injected version. self.addCleanup(_inst.records.pop, registry_id, None) _inst.records['calmjs.artifacts'] = registry # construct a command for the declaration check. cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution( attrs={'name': 'some.package'})) self.assertTrue(calmjs_dist.has_calmjs_artifact_declarations(cmd)) cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution( attrs={'name': 'missing.package'})) self.assertFalse(calmjs_dist.has_calmjs_artifact_declarations(cmd)) cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution( attrs={'name': 'calmjs'})) self.assertFalse(calmjs_dist.has_calmjs_artifact_declarations(cmd))
Example #24
Source File: test_cli.py From calmjs with GNU General Public License v2.0 | 5 votes |
def setup_requirements_json(self): # what kind of bizzaro world do the following users live in? requirements = {"require": {"setuptools": "25.1.6"}} mock_provider = MockProvider({ 'requirements.json': json.dumps(requirements), }) # seriously lolwat? mock_dist = pkg_resources.Distribution( metadata=mock_provider, project_name='calmpy.pip', version='0.0.0') working_set = pkg_resources.WorkingSet() working_set.add(mock_dist) stub_item_attr_value(self, dist, 'default_working_set', working_set) return working_set
Example #25
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_record_internal_normalization(self): make_dummy_dist(self, (( 'entry_points.txt', '[modules]\n' 'some/where/path.js = calmjs.module\n' ),), 'unsafe_name', '1.0') working_set = WorkingSet([self._calmjs_testing_tmpdir]) registry = DummyModuleRegistry('modules', _working_set=working_set) self.assertEqual( 1, len(registry.get_records_for_package('unsafe_name')))
Example #26
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_bad_record(self): working_set = mocks.WorkingSet({__name__: [ 'calmjs.testing.not_a_module = calmjs.testing.not_a_module', ]}) with pretty_logging(stream=mocks.StringIO()) as s: registry = base.BaseModuleRegistry( __name__, _working_set=working_set) self.assertIn( 'ImportError: calmjs.testing.not_a_module not found; ' 'skipping registration', s.getvalue(), ) self.assertEqual(len(registry.raw_entry_points), 1) self.assertEqual(registry.get_record('module'), {}) self.assertEqual(list(registry.iter_records()), [])
Example #27
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_record_internal_normalization(self): make_dummy_dist(self, (( 'entry_points.txt', '[modules]\n' 'record = calmjs.module:ModuleRegistry\n' ),), 'unsafe_name', '1.0') working_set = WorkingSet([self._calmjs_testing_tmpdir]) registry = DummyModuleRegistry('modules', _working_set=working_set) self.assertEqual( 1, len(registry.get_records_for_package('unsafe_name')))
Example #28
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_got_record_cloned(self): # returned records should clones. working_set = mocks.WorkingSet({__name__: [ 'calmjs.testing.module1 = calmjs.testing.module1', ]}) registry = DummyModuleRegistry(__name__, _working_set=working_set) record1 = registry.get_record('calmjs.testing.module1') record2 = registry.get_record('calmjs.testing.module1') self.assertIsNot(record1, record2)
Example #29
Source File: test_npm.py From calmjs with GNU General Public License v2.0 | 5 votes |
def setUp(self): # save working directory remember_cwd(self) # All the pre-made setup. stub_mod_call(self, cli) app = make_dummy_dist(self, ( ('requires.txt', '\n'.join([])), ('package.json', json.dumps({ 'dependencies': {'jquery': '~1.11.0'}, })), ), 'foo', '1.9.0') underscore = make_dummy_dist(self, ( ('requires.txt', '\n'.join([])), ('package.json', json.dumps({ 'dependencies': {'underscore': '~1.8.0'}, })), ), 'underscore', '1.8.0') named = make_dummy_dist(self, ( ('requires.txt', '\n'.join([])), ('package.json', json.dumps({ 'dependencies': {'jquery': '~3.0.0'}, 'name': 'named-js', })), ), 'named', '2.0.0') working_set = WorkingSet() working_set.add(app, self._calmjs_testing_tmpdir) working_set.add(underscore, self._calmjs_testing_tmpdir) working_set.add(named, self._calmjs_testing_tmpdir) stub_item_attr_value(self, dist, 'default_working_set', working_set) stub_check_interactive(self, True)
Example #30
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_dummy_implemented_multiple_modules(self): from calmjs.testing import module1 from calmjs.testing import module2 working_set = mocks.WorkingSet({__name__: [ 'calmjs.testing.module1 = calmjs.testing.module1', 'calmjs.testing.module2 = calmjs.testing.module2', ]}, dist=Distribution(project_name='calmjs.testing')) registry = DummyModuleRegistry(__name__, _working_set=working_set) # it should be merged like so: result = registry.get_records_for_package('calmjs.testing') self.assertEqual(result, { 'calmjs.testing.module1': module1, 'calmjs.testing.module2': module2, }) # root will not work result = registry.get_records_for_package('calmjs') self.assertEqual(result, {}) # likewise not for the module. result = registry.get_records_for_package('calmjs.testing.module1') self.assertEqual(result, {}) # singular result at the module level should still work result = registry.get('calmjs.testing.module2') self.assertEqual(result, {'calmjs.testing.module2': module2})