aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore16
-rw-r--r--python/tests/__init__.py0
-rw-r--r--python/tests/bro_test.py2
-rw-r--r--python/tests/compress_test.py2
-rw-r--r--python/tests/compressor_test.py2
-rw-r--r--python/tests/decompress_test.py2
-rw-r--r--setup.py35
7 files changed, 25 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index 3850f8c..7fe7b1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,17 @@
+# C
*.o
-*.pyc
-*.txt.uncompressed
-*.bro
-*.unbro
bin/
buildfiles/
**/obj/
dist/
+
+# Python
+__pycache__/
+*.py[cod]
+*.so
+*.egg-info/
+
+# Tests
+*.txt.uncompressed
+*.bro
+*.unbro
diff --git a/python/tests/__init__.py b/python/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/python/tests/__init__.py
diff --git a/python/tests/bro_test.py b/python/tests/bro_test.py
index 16ed7ef..ef8c45c 100644
--- a/python/tests/bro_test.py
+++ b/python/tests/bro_test.py
@@ -6,7 +6,7 @@
import subprocess
import unittest
-import _test_utils
+from . import _test_utils
import brotli
PYTHON = _test_utils.PYTHON
diff --git a/python/tests/compress_test.py b/python/tests/compress_test.py
index 7ad6efd..79e7097 100644
--- a/python/tests/compress_test.py
+++ b/python/tests/compress_test.py
@@ -5,7 +5,7 @@
import unittest
-import _test_utils
+from . import _test_utils
import brotli
diff --git a/python/tests/compressor_test.py b/python/tests/compressor_test.py
index 5924e4c..22e3bc5 100644
--- a/python/tests/compressor_test.py
+++ b/python/tests/compressor_test.py
@@ -6,7 +6,7 @@
import functools
import unittest
-import _test_utils
+from . import _test_utils
import brotli
diff --git a/python/tests/decompress_test.py b/python/tests/decompress_test.py
index 536f19a..7a9e9e3 100644
--- a/python/tests/decompress_test.py
+++ b/python/tests/decompress_test.py
@@ -5,7 +5,7 @@
import unittest
-import _test_utils
+from . import _test_utils
import brotli
diff --git a/setup.py b/setup.py
index df6a521..5a9c275 100644
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,8 @@
import os
import platform
import re
+import unittest
+
try:
from setuptools import Extension
from setuptools import setup
@@ -13,7 +15,6 @@ except:
from distutils.core import Extension
from distutils.core import setup
from distutils.command.build_ext import build_ext
-from distutils.cmd import Command
CURR_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
@@ -37,30 +38,10 @@ def get_version():
return '{0}.{1}.{2}'.format(major, minor, patch)
-class TestCommand(Command):
- """ Run all *_test.py scripts in 'tests' folder with the same Python
- interpreter used to run setup.py.
- """
-
- user_options = []
-
- def initialize_options(self):
- pass
-
- def finalize_options(self):
- pass
-
- def run(self):
- import sys, subprocess, glob
-
- test_dir = os.path.join(CURR_DIR, 'python', 'tests')
- os.chdir(test_dir)
-
- for test in glob.glob('*_test.py'):
- try:
- subprocess.check_call([sys.executable, test])
- except subprocess.CalledProcessError:
- raise SystemExit(1)
+def get_test_suite():
+ test_loader = unittest.TestLoader()
+ test_suite = test_loader.discover('python', pattern='*_test.py')
+ return test_suite
class BuildExt(build_ext):
@@ -258,9 +239,10 @@ EXT_MODULES = [
language='c++'),
]
+TEST_SUITE = 'setup.get_test_suite'
+
CMD_CLASS = {
'build_ext': BuildExt,
- 'test': TestCommand,
}
setup(
@@ -275,4 +257,5 @@ setup(
package_dir=PACKAGE_DIR,
py_modules=PY_MODULES,
ext_modules=EXT_MODULES,
+ test_suite=TEST_SUITE,
cmdclass=CMD_CLASS)