Skip to content

Fix brittle flaky tests in core/test_io.py #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions fooof/tests/core/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,45 +112,49 @@ def test_save_fg_fobj(tfg):

assert os.path.exists(os.path.join(TEST_DATA_PATH, file_name + '.json'))

def test_load_json_str():
def test_load_json_str(tfm):
"""Test loading JSON file, with str file specifier.
Loads files from test_save_fm_str.
"""

file_name = 'test_fooof_all'
test_save_fm_str(tfm)

data = load_json(file_name, TEST_DATA_PATH)

assert data

def test_load_json_fobj():
def test_load_json_fobj(tfm):
"""Test loading JSON file, with file object file specifier.
Loads files from test_save_fm_str.
"""

file_name = 'test_fooof_all'
test_save_fm_str(tfm)

with open(os.path.join(TEST_DATA_PATH, file_name + '.json'), 'r') as f_obj:
data = load_json(f_obj, '')

assert data

def test_load_jsonlines():
def test_load_jsonlines(tfg):
"""Test loading JSONlines file.
Loads files from test_save_fg.
"""

res_file_name = 'test_fooofgroup_res'
test_save_fg(tfg)

for data in load_jsonlines(res_file_name, TEST_DATA_PATH):
assert data

def test_load_file_contents():
def test_load_file_contents(tfm):
"""Check that loaded files contain the contents they should.
Note that is this test fails, it likely stems from an issue from saving.
"""

file_name = 'test_fooof_all'
test_load_json_str(tfm)
loaded_data = load_json(file_name, TEST_DATA_PATH)

# Check settings
Expand Down