Commit e38cc8b4 authored by Emanuele Aina's avatar Emanuele Aina

testutils: Move reusable bits to a common module

Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent 1cee8983
......@@ -11,17 +11,13 @@ import sys
import pytest
from testutils import open_relative
# Import modules from the current and parent directory in case pytest is
# invoked in this folder or from the project root
sys.path += ['.', '..']
from testobjects import TestJob
def open_relative(path, *args, **kwargs):
"""Resolve data files relative to this file"""
dir_path = os.path.dirname(os.path.realpath(__file__))
final_path = os.path.join(dir_path, path)
return open(final_path, *args, **kwargs)
def test_load_1450933():
with open_relative('./test_data/job_data_1450933') as f:
rawdata = json.load(f)
......
# Copyright © 2019 Collabora Ltd.
#
# SPDX-License-Identifier: MPL-2.0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
def open_relative(path, *args, **kwargs):
"""Resolve data files relative to this file"""
dir_path = os.path.dirname(os.path.realpath(__file__))
final_path = os.path.join(dir_path, path)
return open(final_path, *args, **kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment