Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da940f5

Browse files
committed
Add pytest header info & remove unused fixtures
Fixtures came from a different project and I forgot to delete them. Add custom header to gather environment info with test results. Remove testdir from pythonpath. pytest handles this on conftest.py
1 parent 5ead8ef commit da940f5

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

appveyor.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ environment:
99
global:
1010
PYTHONUNBUFFERED: True
1111
PYTHONWARNINGS: 'ignore:::wheel.pep425tags:'
12-
PYTHONPATH: C:\testdir
1312
CONDA_BLD: C:\miniconda35
1413

1514
matrix:
@@ -34,11 +33,6 @@ init:
3433
# Prepend newly installed Python to the PATH of this build
3534
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
3635

37-
# Check that we have the expected version, architecture for Python
38-
- python --version
39-
- python -c "import struct; print(struct.calcsize('P') * 8)"
40-
- python -c "import ctypes; print(ctypes.sizeof(ctypes.c_wchar))"
41-
4236
install:
4337
- pip install --upgrade -r requirements.txt
4438

src/tests/conftest.py

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,31 @@
11
# -*- 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?
34

45
"""Helpers for testing."""
56

6-
import io
7-
import os
7+
import ctypes
88
import sys
9+
import sysconfig
910

10-
import pytest
1111
import clr
1212

13+
# Add path for Python.Test & Add References
1314
sys.path.append('C:/testdir/')
1415
clr.AddReference("Python.Test")
1516
clr.AddReference("System.Collections")
1617
clr.AddReference("System.Data")
1718

18-
DIR_PATH = os.path.dirname(__file__)
19-
FILES_DIR = os.path.join(DIR_PATH, 'files')
2019

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"))
2128

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

Comments
 (0)