Skip to content

Commit

Permalink
fix(tests): print traceback from errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Jul 13, 2020
1 parent a73d388 commit 6dc784f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,42 @@ matrix:
- name: "Python 2.7 Basic Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic

- name: "Python 3.6 Basic Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic

- name: "Python 3.7 Basic Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic

- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup

- name: "Python 2.7 Production Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup

- name: "Python 3.6 Production Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup

- name: "Python 3.7 Production Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup

- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup

- name: "Python 3.6 Easy Install"
python: 3.6
Expand Down
6 changes: 6 additions & 0 deletions bench/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ def file_exists(self, path):
if os.environ.get("CI"):
return not subprocess.call(["sudo", "test", "-f", path])
return os.path.isfile(path)

def get_traceback(self):
exc_type, exc_value, exc_tb = sys.exc_info()
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
body = "".join(str(t) for t in trace_list)
return body
7 changes: 7 additions & 0 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def test_init(self, bench_name="test-bench", **kwargs):
self.assert_config(bench_name)


def basic(self):
try:
self.test_init()
except Exception:
print(self.get_traceback())


def test_multiple_benches(self):
for bench_name in ("test-bench-1", "test-bench-2"):
self.init_bench(bench_name)
Expand Down
7 changes: 7 additions & 0 deletions bench/tests/test_setup_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def test_setup_production(self):
bench.utils.exec_cmd("sudo bench disable-production", cwd=bench_path)


def production_setup(self):
try:
self.test_setup_production()
except Exception:
print(self.get_traceback())


def assert_nginx_config(self, bench_name):
conf_src = os.path.join(os.path.abspath(self.benches_path), bench_name, 'config', 'nginx.conf')
conf_dest = "/etc/nginx/conf.d/{bench_name}.conf".format(bench_name=bench_name)
Expand Down

0 comments on commit 6dc784f

Please sign in to comment.