def test_perform_guesswork__ignore(capfd, reset_sys_argv, move_home_pypackage): """If the user responds with 'all', ignore all guesses.""" conf = Config() conf.name = "previously existing" sys.argv = ["py-build", "-i"] guesses = OrderedDict([ ("name", "some name"), ("py_modules", "some_thing"), ("scripts", ["bin/something"]), ("package_data", {"some name": ["thing/data/file_1"]}), ]) with mock.patch.object(guessing, "_guess_at_things", return_value=guesses): with mock.patch.object(guessing, "INPUT", return_value="all"): guessing.perform_guesswork(conf, get_options()) assert conf.name == "previously existing" assert not hasattr(conf, "py_modules") assert not hasattr(conf, "package_data") assert not hasattr(conf, "scripts") out, err = capfd.readouterr() assert "ignoring all guesses" in out assert not err
def test_perform_guesswork__ignore(capfd, reset_sys_argv, move_home_pypackage): """If the user responds with 'all', ignore all guesses.""" conf = Config() conf.name = "previously existing" sys.argv = ["py-build", "-i"] guesses = OrderedDict([ ("name", "some name"), ("py_modules", "some_thing"), ("scripts", ["bin/something"]), ("package_data", { "some name": ["thing/data/file_1"] }), ]) with mock.patch.object(guessing, "_guess_at_things", return_value=guesses): with mock.patch.object(guessing, "INPUT", return_value="all"): guessing.perform_guesswork(conf, get_options()) assert conf.name == "previously existing" assert not hasattr(conf, "py_modules") assert not hasattr(conf, "package_data") assert not hasattr(conf, "scripts") out, err = capfd.readouterr() assert "ignoring all guesses" in out assert not err
def test_perform_guesswork(capfd, reset_sys_argv, move_home_pypackage): """Ensure the user can deselect guesses when using interactive.""" conf = Config() conf.name = "previously existing" sys.argv = ["py-build", "-i"] guesses = OrderedDict([ ("name", "some name"), ("py_modules", "some_thing"), ("scripts", ["bin/something"]), ("package_data", ["thing/data/file_1"]), ]) with mock.patch.object(guessing, "_guess_at_things", return_value=guesses): with mock.patch.object(guessing, "INPUT", side_effect=iter(["1", "-3", "2", ""])): guessing.perform_guesswork(conf, get_options()) assert conf.name == "previously existing" assert not hasattr(conf, "py_modules") assert conf.package_data == {"previously existing": ["thing/data/file_1"]} assert conf.scripts == ["bin/something"] out, err = capfd.readouterr() assert "name will not be guessed" in out assert "py_modules will not be guessed" in out assert not err
def test_perform_guesswork(capfd, reset_sys_argv, move_home_pypackage): """Ensure the user can deselect guesses when using interactive.""" conf = Config() conf.name = "previously existing" sys.argv = ["py-build", "-i"] guesses = OrderedDict([ ("name", "some name"), ("py_modules", "some_thing"), ("scripts", ["bin/something"]), ("package_data", ["thing/data/file_1"]), ]) with mock.patch.object(guessing, "_guess_at_things", return_value=guesses): with mock.patch.object(guessing, "INPUT", side_effect=iter(["1", "-3", "2", ""])): guessing.perform_guesswork(conf, get_options()) assert conf.name == "previously existing" assert not hasattr(conf, "py_modules") assert conf.package_data == {"previously existing": ["thing/data/file_1"]} assert conf.scripts == ["bin/something"] out, err = capfd.readouterr() assert "name will not be guessed" in out assert "py_modules will not be guessed" in out assert not err
def test_standard_attributes__re_config(reset_sys_argv): """If reconfig is set, all standard attributes should be unconfigured.""" conf = Config() conf.name = "something" sys.argv = ["py-build", "-r"] attrs = configure.standard_attributes(conf, get_options()) expected = list(conf._KEYS.keys())[:conf._STD_TO_EXTD_INDEX] assert attrs == expected
def test_standard_attributes__re_config(reset_sys_argv): """If reconfig is set, all standard attributes should be unconfigured.""" conf = Config() conf.name = "something" sys.argv = ["py-build", "-r"] attrs = configure.standard_attributes(conf, get_options()) expected = list(conf._KEYS.keys())[:17] assert attrs == expected
def test_standard_attributes(reset_sys_argv, move_home_pypackage): """Ensure the standard attribute set.""" conf = Config() expected_attrs = list(conf._KEYS.keys())[:conf._STD_TO_EXTD_INDEX] conf.name = "foobar" conf.classifiers = ["fake classifier"] expected_attrs.remove("name") expected_attrs.remove("classifiers") attrs = configure.standard_attributes(conf, get_options()) assert attrs == expected_attrs
def test_standard_attributes(reset_sys_argv, move_home_pypackage): """Ensure the standard attribute set.""" conf = Config() expected_attrs = list(conf._KEYS.keys())[:17] conf.name = "foobar" conf.classifiers = ["fake classifier"] expected_attrs.remove("name") expected_attrs.remove("classifiers") attrs = configure.standard_attributes(conf, get_options()) assert attrs == expected_attrs
def test_additional_tests_require(runner): """If there are provided tests_require, they should be mixed in.""" # we get runner-cov here becuase we provide a name conf = Config(name="test", test_runner=runner, tests_require=["my_thing"]) assert conf.tests_require == ["my_thing", runner, "{}-cov".format(runner)] assert conf.runner_args[-1] == "test" # change our name here, we should get our new name in runner_args conf.name = "changed" # also we can reset tests_require and they should re-populate conf.tests_require = ["my_thing"] conf._verify() assert conf.runner_args[-1] == "changed"
def test_additional_tests_require(runner): """If there are provided tests_require, they should be mixed in.""" # we get runner-cov here becuase we provide a name conf = Config(name="test", test_runner=runner, tests_require=["my_thing"]) assert conf.tests_require == ["my_thing", runner, "{}-cov".format(runner)] assert conf.runner_args[-1] == "test" # change our name here, we should get our new name in runner_args conf.name = "changed" # also we can reset tests_require and they should re-populate conf.tests_require = ["my_thing"] conf._verify() assert conf.runner_args[-1] == "changed"