Debian Codegraph @

tests/base/data.py

raw symbols SCIP
1 import os
2 import unittest
3
4 import pytest
5
6
7 local_dir = os.path.dirname(__file__)
8 test_data_path = os.path.abspath(os.path.join(local_dir, '..', 'data'))
9 del local_dir
10
11
12 class PygletTestCase(unittest.TestCase):
13 """
14 Base class for pyglet tests.
15 Specifies helper methods for all tests.
16 """
17 @staticmethod
18 def get_test_data_file(*file_parts):
19 """
20 Get a file from the test data directory in an OS independent way. Supply relative file
21 name as you would in os.path.join().
22 """
23 return os.path.join(test_data_path, *file_parts)
24
25
26 class TestDataFixture:
27 """Fixture for accessing test data."""
28 def __init__(self):
29 local_dir = os.path.dirname(__file__)
30 self._test_data_path = os.path.abspath(os.path.join(local_dir, '..', 'data'))
31
32 def get_file(self, *file_parts):
33 """
34 Get a file from the test data directory in an OS independent way. Supply relative file
35 name as you would in os.path.join().
36 """
37 return os.path.join(self._test_data_path, *file_parts)
38
39
40 @pytest.fixture(scope="session")
41 def test_data():
42 return TestDataFixture()