def test_passes_kwargs_to_all_specs(self): random_kwargs = { "foo": random.randint(100, 200), "bar%d" % random.randint(100, 200): True } spec1, spec2 = generate_two_specs() with patched_specs(spec1, spec2): specs.detect(**random_kwargs) spec1.assert_called_with(**random_kwargs) spec2.assert_called_with(**random_kwargs)
def execute(args, parser): prefix = context.target_prefix if not is_conda_environment(prefix): raise EnvironmentLocationNotFound(prefix) try: url_scheme = args.file.split("://", 1)[0] if url_scheme in CONDA_SESSION_SCHEMES: filename = args.file else: filename = abspath(expanduser(expandvars(args.file))) spec = specs.detect(name=args.name, filename=filename, directory=os.getcwd()) env = spec.environment if args.prefix is None and args.name is None: args.name = env.name except SpecNotFound: raise active_pkgs = dict(map(_get_name_tuple, get_packages(prefix))) specification_pkgs = [] if 'conda' in env.dependencies: specification_pkgs = specification_pkgs + env.dependencies['conda'] if 'pip' in env.dependencies: specification_pkgs = specification_pkgs + env.dependencies['pip'] exitcode, output = compare_packages(active_pkgs, specification_pkgs) if context.json: stdout_json(output) else: print('\n'.join(map(str, output))) return exitcode
def test_raises_exception_if_no_detection(self): spec1 = generate_two_specs()[0] spec1.msg = 'msg' with patched_specs(spec1) as all_specs: with self.assertRaises(SpecNotFound): specs.detect(name="foo")
def test_dispatches_to_registered_specs(self): spec1, spec2 = generate_two_specs() with patched_specs(spec1, spec2) as all_specs: actual = specs.detect(name="foo") self.assertEqual(actual, spec2)