def test_statement_with_new_play_types(): with open(get_adjacent_file("invoice_new_plays.json")) as f: invoice = json.loads(f.read()) with open(get_adjacent_file("new_plays.json")) as f: plays = json.loads(f.read()) with pytest.raises(ValueError) as exception_info: statement(invoice, plays) assert "unknown type" in str(exception_info.value)
def test_example_statement(): with open(get_adjacent_file("invoice.json")) as f: invoice = json.loads(f.read()) with open(get_adjacent_file("plays.json")) as f: plays = json.loads(f.read()) statement = Statement.from_json(invoice=invoice, plays=plays) presentation = Text(statement) verify(str(presentation))
def test_assert_against_file_fails_with_reporter(self): reporter = TestingReporter() file_path = get_adjacent_file("manual_file.approved.txt") try: assert_against_file("This text is NOT in a file", file_path, reporter ) except ApprovalException: pass self.assertTrue(reporter.called)
def __init__(self) -> None: self.load(get_adjacent_file("reporters.json"))
def __init__(self): self.load(get_adjacent_file('reporters.json'))
def test_verify_file(self): name = "testFile.txt" filename = get_adjacent_file(name) verify_file(filename, self.reporter)
def test_verify_file_with_actual_windows_1252_encoding(self) -> None: name = "exampleFile_Actual_Windows1252.txt" filename = get_adjacent_file(name) verify_file(filename, self.reporter)
def test_verify_file_binary_file(self) -> None: name = "icon.png" filename = get_adjacent_file(name) verify_file(filename)
def load_json(file_name: str): with open(get_adjacent_file(file_name)) as f: return json.loads(f.read())
def test_verify_file_with_windows_1252_encoding(self): name = "exampleFileWindows1252.txt" filename = get_adjacent_file(name) verify_file(filename, self.reporter, encoding="cp1252", newline="\r\n")
def __init__(self): self.load(get_adjacent_file('reporters.json')) self.add_fallback_reporter_config(["PythonNative", "python", [get_adjacent_file("python_native_reporter.py")]])
def test_exist_file_with_modified_extension(self): verify_file(get_adjacent_file("sample.xml"), options=Options().for_file.with_extension(".json"))
def test_exist_file_extension(self): verify_file(get_adjacent_file("sample.xml"))
def test_verify_bytes(self) -> None: # begin-snippet: verify_binary_image name = "icon.png" filename = get_adjacent_file(name) with open(filename, mode='rb') as f: verify_binary(f.read(), ".png")
def test_example_statement(): with open(get_adjacent_file("invoice.json")) as f: invoice = json.loads(f.read()) with open(get_adjacent_file("plays.json")) as f: plays = json.loads(f.read()) verify(statement(invoice, plays))
def test_assert_against_file_works(self): file_path = get_adjacent_file("manual_file.approved.txt") assert_against_file("This text is in a file", file_path)
def test_verify_file(self) -> None: name = "exampleFile.txt" filename = get_adjacent_file(name) verify_file(filename, self.reporter)
def hidden_test_verify_file_with_windows_1252_encoding(self): name = "exampleFileWindows1252.txt" filename = get_adjacent_file(name) verify_file(filename, self.reporter)