Skip to content

Instantly share code, notes, and snippets.

@devcpu
Last active September 1, 2022 09:32
Show Gist options
  • Save devcpu/1144a7dd8f78e15104d31afcc08beffa to your computer and use it in GitHub Desktop.
Save devcpu/1144a7dd8f78e15104d31afcc08beffa to your computer and use it in GitHub Desktop.
python:pytest
assert isinstance(got, DWH)
assert got is None
assert re.match(r'h\d{5,10}\.stratoserver\.net', got)
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))
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