def test_configuration_checks_groups(self): extractor = passgithelper.RegexSearchExtractor('^username: (.*)$', '_username') config = configparser.ConfigParser() config.read_string(r"""[test] regex_username=^foo: .*$""") with pytest.raises(ValueError): extractor.configure(config['test'])
def test_smoke(self): extractor = passgithelper.RegexSearchExtractor('^username: (.*)$', '') assert extractor.get_value( 'foo', ['thepassword', 'somethingelse', 'username: user', 'username: second ignored']) == 'user'
def test_configuration(self): extractor = passgithelper.RegexSearchExtractor('^username: (.*)$', '_username') config = configparser.ConfigParser() config.read_string(r"""[test] regex_username=^foo: (.*)$""") extractor.configure(config['test']) assert extractor._regex.pattern == r'^foo: (.*)$'
def test_configuration_checks_groups(self) -> None: extractor = passgithelper.RegexSearchExtractor("^username: (.*)$", "_username") config = configparser.ConfigParser() config.read_string(r"""[test] regex_username=^foo: .*$""") with pytest.raises(ValueError, match="must contain"): extractor.configure(config["test"])
def test_configuration(self) -> None: extractor = passgithelper.RegexSearchExtractor("^username: (.*)$", "_username") config = configparser.ConfigParser() config.read_string(r"""[test] regex_username=^foo: (.*)$""") extractor.configure(config["test"]) assert extractor._regex.pattern == r"^foo: (.*)$"
def test_smoke(self): extractor = passgithelper.RegexSearchExtractor("^username: (.*)$", "") assert (extractor.get_value( "foo", [ "thepassword", "somethingelse", "username: user", "username: second ignored", ], ) == "user")
def test_missing_group(self): with pytest.raises(ValueError): passgithelper.RegexSearchExtractor('^username: .*$', '')
def test_missing_group(self) -> None: with pytest.raises(ValueError, match="must contain"): passgithelper.RegexSearchExtractor("^username: .*$", "")