Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell Travis to skip a test, but continue to include it in my main test suite?

I am using Django 1.8 and I have a management command that geocodes some items in my database, which requires an internet connection.

I have written a test for this management command. However, the test runs the script, so it also requires an internet connection.

After pushing the test to GitHub, my CI is broken, because Travis doesn't have an outside internet connection so it fails on this test.

I want to keep this test, and I'd like to continue to include it in python manage.py test when run locally.

However, is there a way I can explicitly tell Travis not to bother with this particular test?

Alternatively, is there some other clean way that I can keep this test as part of my main test suite, but stop it breaking Travis?

like image 699
Richard Avatar asked Dec 14 '22 13:12

Richard


1 Answers

Maybe you could decorate your test with @unittest.skipIf(condition, reason) to test for the presence of a Travis CI specific environment variable to skip it or not. For example:

import os
...
@unittest.skipIf("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true", "Skipping this test on Travis CI.")
def test_example(self):
  ...
like image 153
Dominic Jodoin Avatar answered Jan 14 '23 12:01

Dominic Jodoin