Skip to content
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

tests: use pathlib #121

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/baseline_data.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-2020 Richard Hull and contributors
# See LICENSE.rst for details.

import io
import json
import os.path
from pathlib import Path


__all__ = ['primitives', 'get_reference_data']
Expand All @@ -32,7 +31,13 @@ def primitives(device, draw):


def get_reference_data(fname):
dirname = os.path.abspath(os.path.dirname(__file__))
fpath = os.path.join(dirname, 'reference', 'data', fname + '.json')
with io.open(fpath) as f:
"""
Load JSON reference data.

:param fname: Filename without extension.
:type fname: str
"""
base_dir = Path(__file__).resolve().parent
fpath = base_dir.joinpath('reference', 'data', fname + '.json')
with fpath.open() as f:
return json.load(f)