Skip to content

Commit

Permalink
Use unittest2 as test runner.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
pmdarrow committed Dec 3, 2015
1 parent f740393 commit d78386f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
python setup.py test
unit2 discover

release:
python setup.py sdist upload
Expand Down
4 changes: 4 additions & 0 deletions locust/test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
from copy import copy
from io import BytesIO
import sys
import six

from locust import events
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 1 addition & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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',
)

0 comments on commit d78386f

Please sign in to comment.