From d78386f0e22a620d35f4a12de61a1d2a3f4db202 Mon Sep 17 00:00:00 2001 From: Peter Darrow Date: Thu, 3 Dec 2015 15:25:49 -0400 Subject: [PATCH] Use unittest2 as test runner. The setuptools / unittest test runner is very flaky on Python 3. This also encourages a single way to run tests: unit2 discover (called by tox or run directly). --- .travis.yml | 18 +++++++++--------- Makefile | 2 +- locust/test/testcases.py | 4 ++++ setup.py | 22 +--------------------- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b7d1f0a16..6ff1da6971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: python -python: - - "2.6" - - "2.7" - - "3.3" - - "3.4" - - "3.5" -# command to install dependencies +env: + - TOXENV=py26 + - TOXENV=py27 + - TOXENV=py33 + - TOXENV=py34 + - TOXENV=py35 install: - sudo apt-get install -y libevent-dev -# command to run tests -script: python setup.py test + - pip install tox +script: + - tox diff --git a/Makefile b/Makefile index f5260bdd24..a88395564e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ test: - python setup.py test + unit2 discover release: python setup.py sdist upload diff --git a/locust/test/testcases.py b/locust/test/testcases.py index 8dc6492809..dfe201f9cc 100644 --- a/locust/test/testcases.py +++ b/locust/test/testcases.py @@ -5,6 +5,7 @@ import unittest from copy import copy from io import BytesIO +import sys import six from locust import events @@ -114,6 +115,9 @@ class LocustTestCase(unittest.TestCase): safe to register any custom event handlers within the test. """ def setUp(self): + # Prevent args passed to test runner from being passed to Locust + del sys.argv[1:] + self._event_handlers = {} for name in dir(events): event = getattr(events, name) diff --git a/setup.py b/setup.py index 81e96a2641..f81cea93b7 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,9 @@ # encoding: utf-8 -from setuptools import setup, find_packages, Command -import sys, os +from setuptools import setup, find_packages version = '0.7.3' - -class Unit2Discover(Command): - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - import sys, subprocess - basecmd = ['unit2', 'discover'] - errno = subprocess.call(basecmd) - raise SystemExit(errno) - - setup( name='locustio', version=version, @@ -52,11 +34,9 @@ def run(self): include_package_data=True, zip_safe=False, install_requires=["gevent==1.1.rc1", "flask>=0.10.1", "requests>=2.4.1", "msgpack-python>=0.4.2", "six>=1.10.0"], - tests_require=['unittest2', 'mock', 'pyzmq'], entry_points={ 'console_scripts': [ 'locust = locust.main:main', ] }, - test_suite='unittest2.collector', )