Last active
September 1, 2022 09:32
-
-
Save devcpu/1144a7dd8f78e15104d31afcc08beffa to your computer and use it in GitHub Desktop.
python:pytest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert isinstance(got, DWH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert got is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert re.match(r'h\d{5,10}\.stratoserver\.net', got) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert got |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with pytest.raises(Exception) as exception: # noqa: F841 | |
dbh.do_transaction(sql) | |
assert exception is not None | |
assert re.match(r'.*Data source name not found and no default driver specified.*', str(exception)) | |
try: | |
got = dbh.do(f'EXECUTE dsp_getAllTicketParameters {ticket_id}') | |
assert len(got) > 0 | |
except Exception as excp: | |
assert re.match(r'.*ticket not found.*', str(excp)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with patch("sys.argv", ["main", "hwn23456.vs.rz-ip.net"]): | |
parser = get_args() | |
assert parser.hwns[0] == "hwn23456.vs.rz-ip.net" | |
with pytest.raises(SystemExit) as exception: | |
with patch("sys.argv", ["main"]): | |
get_args() | |
assert exception.type == SystemExit | |
out, err = capsys.readouterr() | |
assert re.findall(".*required: HWNName", err, re.MULTILINE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment