|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -# TODO: move tests one out of src. Pythonnet doesn't run... |
| 2 | +# TODO: move tests one out of src to project root. |
| 3 | +# TODO: travis has numpy on their workers. Maybe add tests? |
3 | 4 |
|
4 | 5 | """Helpers for testing."""
|
5 | 6 |
|
6 |
| -import io |
7 |
| -import os |
| 7 | +import ctypes |
8 | 8 | import sys
|
| 9 | +import sysconfig |
9 | 10 |
|
10 |
| -import pytest |
11 | 11 | import clr
|
12 | 12 |
|
| 13 | +# Add path for Python.Test & Add References |
13 | 14 | sys.path.append('C:/testdir/')
|
14 | 15 | clr.AddReference("Python.Test")
|
15 | 16 | clr.AddReference("System.Collections")
|
16 | 17 | clr.AddReference("System.Data")
|
17 | 18 |
|
18 |
| -DIR_PATH = os.path.dirname(__file__) |
19 |
| -FILES_DIR = os.path.join(DIR_PATH, 'files') |
20 | 19 |
|
| 20 | +def pytest_report_header(config): |
| 21 | + """Generate extra report headers""" |
| 22 | + # FIXME: https://github.com/pytest-dev/pytest/issues/2257 |
| 23 | + is_64bits = sys.maxsize > 2**32 |
| 24 | + arch = "x64" if is_64bits else "x86" |
| 25 | + ucs = ctypes.sizeof(ctypes.c_wchar) |
| 26 | + libdir = sysconfig.get_config_var("LIBDIR") |
| 27 | + shared = bool(sysconfig.get_config_var("Py_ENABLE_SHARED")) |
21 | 28 |
|
22 |
| -@pytest.fixture() |
23 |
| -def filepath(): |
24 |
| - """Returns full file path for test files.""" |
25 |
| - |
26 |
| - def make_filepath(filename): |
27 |
| - # http://stackoverflow.com/questions/18011902/parameter-to-a-fixture |
28 |
| - # Alternate solution is to use paramtrization `inderect=True` |
29 |
| - # http://stackoverflow.com/a/33879151 |
30 |
| - # Syntax is noisy and requires specific variable names |
31 |
| - return os.path.join(FILES_DIR, filename) |
32 |
| - |
33 |
| - return make_filepath |
34 |
| - |
35 |
| - |
36 |
| -@pytest.fixture() |
37 |
| -def load_file(filepath): |
38 |
| - """Opens filename with encoding and return its contents.""" |
39 |
| - |
40 |
| - def make_load_file(filename, encoding='utf-8'): |
41 |
| - # http://stackoverflow.com/questions/18011902/parameter-to-a-fixture |
42 |
| - # Alternate solution is to use paramtrization `inderect=True` |
43 |
| - # http://stackoverflow.com/a/33879151 |
44 |
| - # Syntax is noisy and requires specific variable names |
45 |
| - # And seems to be limited to only 1 argument. |
46 |
| - with io.open(filepath(filename), encoding=encoding) as f: |
47 |
| - return f.read().strip() |
48 |
| - |
49 |
| - return make_load_file |
50 |
| - |
51 |
| - |
52 |
| -@pytest.fixture() |
53 |
| -def get_stream(filepath): |
54 |
| - def make_stream(filename, encoding='utf-8'): |
55 |
| - return io.open(filepath(filename), encoding=encoding) |
56 |
| - |
57 |
| - return make_stream |
| 29 | + header = ("Arch: {arch}, UCS: {ucs}, LIBDIR: {libdir}, " |
| 30 | + "Py_ENABLE_SHARED: {shared}".format(**locals())) |
| 31 | + return header |
0 commit comments