Ejemplo n.º 1
0
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))
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def __init__(self) -> None:
     self.load(get_adjacent_file("reporters.json"))
 def __init__(self):
     self.load(get_adjacent_file('reporters.json'))
Ejemplo n.º 6
0
 def test_verify_file(self):
     name = "testFile.txt"
     filename = get_adjacent_file(name)
     verify_file(filename, self.reporter)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def test_verify_file_binary_file(self) -> None:
     name = "icon.png"
     filename = get_adjacent_file(name)
     verify_file(filename)
Ejemplo n.º 9
0
def load_json(file_name: str):
    with open(get_adjacent_file(file_name)) as f:
        return json.loads(f.read())
Ejemplo n.º 10
0
 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")]])
Ejemplo n.º 12
0
 def test_verify_file(self):
     name = "testFile.txt"
     filename = get_adjacent_file(name)
     verify_file(filename, self.reporter)
Ejemplo n.º 13
0
 def test_exist_file_with_modified_extension(self):
     verify_file(get_adjacent_file("sample.xml"),
                 options=Options().for_file.with_extension(".json"))
Ejemplo n.º 14
0
 def test_exist_file_extension(self):
     verify_file(get_adjacent_file("sample.xml"))
Ejemplo n.º 15
0
 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")
Ejemplo n.º 16
0
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))
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 def test_verify_file(self) -> None:
     name = "exampleFile.txt"
     filename = get_adjacent_file(name)
     verify_file(filename, self.reporter)
 def __init__(self):
     self.load(get_adjacent_file('reporters.json'))
Ejemplo n.º 20
0
 def hidden_test_verify_file_with_windows_1252_encoding(self):
     name = "exampleFileWindows1252.txt"
     filename = get_adjacent_file(name)
     verify_file(filename, self.reporter)