Last active
August 13, 2020 19:51
-
-
Save sahansk2/07d374a4e96432775be69f10efb70612 to your computer and use it in GitHub Desktop.
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
import pytest | |
def read_file(): | |
print("Running read_file") | |
with open("test.txt", "r") as test_file: | |
data = test_file.read() | |
print("DATA: {}".format(data if data else "[[[[EMPTY]]]]")) | |
return data | |
def write_file(data): | |
print("Running write_file with data: {}".format(repr(data))) | |
with open("test.txt", "w") as test_file: | |
test_file.write(data) | |
@pytest.fixture | |
def test_file(tmpdir): | |
print("Running test_file") | |
with open('test.txt', 'w'): | |
pass | |
def test_dataset_1(test_file): | |
print("Running test_dataset_1") | |
write_file("dataset_1") | |
read_file() | |
def test_dataset_2(test_file): | |
print("Running test_dataset_2") | |
data = read_file() | |
if data: | |
print("Data has content: {}".format(data)) | |
else: | |
print("Data is empty") | |
write_file("dataset_2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: