File: data.py

package info (click to toggle)
pyglet 2.0.17%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,560 kB
  • sloc: python: 80,579; xml: 50,988; ansic: 171; makefile: 146
file content (42 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import unittest

import pytest


local_dir = os.path.dirname(__file__)
test_data_path = os.path.abspath(os.path.join(local_dir, '..', 'data'))
del local_dir


class PygletTestCase(unittest.TestCase):
    """
    Base class for pyglet tests.
    Specifies helper methods for all tests.
    """
    @staticmethod
    def get_test_data_file(*file_parts):
        """
        Get a file from the test data directory in an OS independent way. Supply relative file
        name as you would in os.path.join().
        """
        return os.path.join(test_data_path, *file_parts)


class TestDataFixture:
    """Fixture for accessing test data."""
    def __init__(self):
        local_dir = os.path.dirname(__file__)
        self._test_data_path = os.path.abspath(os.path.join(local_dir, '..', 'data'))

    def get_file(self, *file_parts):
        """
        Get a file from the test data directory in an OS independent way. Supply relative file
        name as you would in os.path.join().
        """
        return os.path.join(self._test_data_path, *file_parts)


@pytest.fixture(scope="session")
def test_data():
    return TestDataFixture()