diff --git a/monkeysign/tests/test_ui.py b/monkeysign/tests/test_ui.py
index c110cc03d252d4c57e3c2104d03623ad837b836c..deeac968e3f5186e7ec7f30fa9dd41dbd8bc77f8 100755
--- a/monkeysign/tests/test_ui.py
+++ b/monkeysign/tests/test_ui.py
@@ -94,7 +94,7 @@ class CliBaseTest(unittest.TestCase):
         '''
         directory, basename = os.path.split(self.argv[0])
         path, directory = os.path.split(os.path.realpath(directory))
-        if directory == 'scripts' or basename == 'setup.py':
+        if directory == 'scripts' or basename == 'setup.py' or 'pytest' in basename:
             # default to run from source dir. this is necessary for
             # ./scripts/monkeysign --test and ./setup.py test
             execfile(os.path.dirname(__file__) + '/../../scripts/monkeysign')