[test] toxify tests
authordrebs <drebs@leap.se>
Wed, 6 Jul 2016 06:43:49 +0000 (08:43 +0200)
committerKali Kaneko <kali@leap.se>
Mon, 11 Jul 2016 14:41:50 +0000 (16:41 +0200)
15 files changed:
pkg/requirements-testing.pip [deleted file]
setup.cfg
src/leap/common/events/tests/__init__.py [deleted file]
src/leap/common/tests/__init__.py [deleted file]
tests/config/test_baseconfig.py [moved from src/leap/common/config/tests/test_baseconfig.py with 95% similarity]
tests/config/test_get_path_prefix.py [moved from src/leap/common/config/tests/test_get_path_prefix.py with 96% similarity]
tests/events/test_auth.py [moved from src/leap/common/events/tests/test_auth.py with 96% similarity]
tests/events/test_events.py [moved from src/leap/common/events/tests/test_events.py with 100% similarity]
tests/events/test_zmq_components.py [moved from src/leap/common/events/tests/test_zmq_components.py with 100% similarity]
tests/test_certs.py [moved from src/leap/common/tests/test_certs.py with 94% similarity]
tests/test_check.py [moved from src/leap/common/tests/test_check.py with 100% similarity]
tests/test_http.py [moved from src/leap/common/tests/test_http.py with 94% similarity]
tests/test_memoize.py [moved from src/leap/common/tests/test_memoize.py with 100% similarity]
tests/testing/test_basetest.py [moved from src/leap/common/testing/test_basetest.py with 98% similarity]
tox.ini [new file with mode: 0644]

diff --git a/pkg/requirements-testing.pip b/pkg/requirements-testing.pip
deleted file mode 100644 (file)
index c5a3ad0..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-mock
-setuptools-trial
-pep8
index 7828918..431f4b9 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [aliases]
-test = trial
+test=pytest
 
 [pep8]
 exclude = versioneer.py,_version.py,*.egg,build,dist,docs
diff --git a/src/leap/common/events/tests/__init__.py b/src/leap/common/events/tests/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/leap/common/tests/__init__.py b/src/leap/common/tests/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
similarity index 95%
rename from src/leap/common/config/tests/test_baseconfig.py
rename to tests/config/test_baseconfig.py
index e17e82d..22358ec 100644 (file)
@@ -100,7 +100,7 @@ sample_spec = {
 }
 
 
-class TestConfig(BaseConfig):
+class Config(BaseConfig):
     """
     BaseConfig implementation for testing purposes only.
     """
@@ -149,16 +149,16 @@ class BaseConfigTest(BaseLeapTest):
 
     def _get_config(self, fromfile=False, data=sample_config):
         """
-        Helper that returns a TestConfig object using the data parameter
+        Helper that returns a Config object using the data parameter
         or a sample data.
 
         :param fromfile: sets if we should use a file or a string
         :fromfile type: bool
-        :param data: sets the data to be used to load in the TestConfig object
+        :param data: sets the data to be used to load in the Config object
         :data type: dict (valid json)
-        :rtype: TestConfig
+        :rtype: Config
         """
-        config = TestConfig()
+        config = Config()
 
         loaded = False
         if fromfile:
@@ -198,7 +198,7 @@ class BaseConfigTest(BaseLeapTest):
         self.assertEqual(config.get_gateways(), sample_config["gateways"])
 
     def test_safe_get_value_no_config(self):
-        config = TestConfig()
+        config = Config()
 
         with self.assertRaises(AssertionError):
             config.get_version()
@@ -213,7 +213,7 @@ class BaseConfigTest(BaseLeapTest):
         self.assertTrue(config.loaded())
 
     def test_not_loaded(self):
-        config = TestConfig()
+        config = Config()
         self.assertFalse(config.loaded())
 
     def test_save_and_load(self):
@@ -222,7 +222,7 @@ class BaseConfigTest(BaseLeapTest):
         config_file = 'test_config.json'
         self.assertTrue(config.save([config_file]))
 
-        config_saved = TestConfig()
+        config_saved = Config()
         config_file_path = self.get_tempfile(config_file)
         self.assertTrue(config_saved.load(config_file_path, relative=False))
 
@@ -243,7 +243,7 @@ class BaseConfigTest(BaseLeapTest):
         conf = copy.deepcopy(sample_config)
         conf['default_language'] = lang
         json_string = json.dumps(conf)
-        config = TestConfig()
+        config = Config()
         config.load(data=json_string)
 
         return config
similarity index 96%
rename from src/leap/common/config/tests/test_get_path_prefix.py
rename to tests/config/test_get_path_prefix.py
index 27824fc..e383a7e 100644 (file)
@@ -36,7 +36,7 @@ class GetPathPrefixTest(BaseLeapTest):
     Note: we only are testing that the path is correctly returned and that if
     we are not in a bundle (standalone=False) then the paths are different.
 
-    dirspec calculates the correct path using different methods and dlls
+    xdg calculates the correct path using different methods and dlls
     (in case of Windows) so we don't implement tests to check if the paths
     are the correct ones.
     """
similarity index 96%
rename from src/leap/common/events/tests/test_auth.py
rename to tests/events/test_auth.py
index 78ffd9f..5442ebd 100644 (file)
@@ -33,8 +33,6 @@ from txzmq.test import _wait
 class ZmqAuthTestCase(unittest.TestCase, BaseLeapTest):
 
     def setUp(self):
-        self.setUpEnv(launch_events_server=False)
-
         self.factory = ZmqFactory()
         self._config_prefix = os.path.join(self.tempdir, "leap", "events")
 
@@ -47,7 +45,6 @@ class ZmqAuthTestCase(unittest.TestCase, BaseLeapTest):
 
     def tearDown(self):
         self.factory.shutdown()
-        self.tearDownEnv()
 
     def test_curve_auth(self):
         self.auth_req.start()
similarity index 94%
rename from src/leap/common/tests/test_certs.py
rename to tests/test_certs.py
index 8ebc0f4..b06fbf8 100644 (file)
@@ -18,7 +18,6 @@
 Tests for:
     * leap/common/certs.py
 """
-import os
 import time
 
 try:
@@ -28,10 +27,9 @@ except ImportError:
 
 from leap.common import certs
 from leap.common.testing.basetest import BaseLeapTest
+from leap.common.testing.https_server import where
 
-TEST_CERT_PEM = os.path.join(
-    os.path.split(__file__)[0],
-    '..', 'testing', "leaptest_combined_keycert.pem")
+TEST_CERT_PEM = where("leaptest_combined_keycert.pem")
 
 # Values from the test cert file:
 # Not Before: Sep  3 17:52:16 2013 GMT
@@ -43,10 +41,10 @@ CERT_NOT_AFTER = (2023, 9, 1, 17, 52, 16, 4, 244, 0)
 class CertsTest(BaseLeapTest):
 
     def setUp(self):
-        self.setUpEnv()
+        pass
 
     def tearDown(self):
-        self.tearDownEnv()
+        pass
 
     def test_should_redownload_if_no_cert(self):
         self.assertTrue(certs.should_redownload(certfile=""))
similarity index 94%
rename from src/leap/common/tests/test_http.py
rename to tests/test_http.py
index f44550f..d5526e6 100644 (file)
@@ -18,7 +18,6 @@
 Tests for:
     * leap/common/http.py
 """
-import os
 try:
     import unittest2 as unittest
 except ImportError:
@@ -26,10 +25,9 @@ except ImportError:
 
 from leap.common import http
 from leap.common.testing.basetest import BaseLeapTest
+from leap.common.testing.https_server import where
 
-TEST_CERT_PEM = os.path.join(
-    os.path.split(__file__)[0],
-    '..', 'testing', "leaptest_combined_keycert.pem")
+TEST_CERT_PEM = where("leaptest_combined_keycert.pem")
 
 
 class HTTPClientTest(BaseLeapTest):
similarity index 98%
rename from src/leap/common/testing/test_basetest.py
rename to tests/testing/test_basetest.py
index ec42a62..8be7aba 100644 (file)
@@ -83,10 +83,10 @@ class TestInitBaseLeapTest(BaseLeapTest):
     """
 
     def setUp(self):
-        self.setUpEnv()
+        pass
 
     def tearDown(self):
-        self.tearDownEnv()
+        pass
 
     def test_path_is_changed(self):
         """tests whether we have changed the PATH env var"""
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..5ca1ca4
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,17 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py27
+
+[testenv]
+commands = py.test {posargs}
+deps =
+    pytest
+    mock
+    setuptools-trial
+    pep8
+setenv =
+    HOME=/tmp