Mercurial > hgsubversion
comparison tests/run.py @ 644:95abc4cfc78f
tests: improve import logic
We already had some logic some logic to make us import the local
modules, but it failed under certain circumstances. I suspect that it
had to do with absolute vs. relative paths. Regardless of what the
root cause was, this fixes it.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Wed, 14 Jul 2010 15:39:21 +0200 |
| parents | c38fe89a5cbc |
| children | ab454ee515d4 |
comparison
equal
deleted
inserted
replaced
| 643:d2ef7220a079 | 644:95abc4cfc78f |
|---|---|
| 2 import os | 2 import os |
| 3 import sys | 3 import sys |
| 4 import unittest | 4 import unittest |
| 5 | 5 |
| 6 def tests(): | 6 def tests(): |
| 7 import test_util | |
| 8 import test_binaryfiles | 7 import test_binaryfiles |
| 9 import test_diff | 8 import test_diff |
| 10 import test_externals | 9 import test_externals |
| 11 import test_fetch_branches | 10 import test_fetch_branches |
| 12 import test_fetch_command | 11 import test_fetch_command |
| 60 if options.verbose: | 59 if options.verbose: |
| 61 testargs = { 'descriptions': 3, 'verbosity': 2 } | 60 testargs = { 'descriptions': 3, 'verbosity': 2 } |
| 62 else: | 61 else: |
| 63 testargs = {'descriptions': 2} | 62 testargs = {'descriptions': 2} |
| 64 | 63 |
| 65 # make sure our copy of hgsubversion gets imported | |
| 66 sys.path.append(os.path.dirname(os.path.dirname(__file__))) | 64 sys.path.append(os.path.dirname(os.path.dirname(__file__))) |
| 67 | 65 |
| 68 if options.demandimport: | 66 if options.demandimport: |
| 69 from mercurial import demandimport | 67 from mercurial import demandimport |
| 70 demandimport.enable() | 68 demandimport.enable() |
| 71 | 69 |
| 70 # make sure our copy of hgsubversion gets imported by loading test_util | |
| 71 import test_util | |
| 72 test_util.TestBase | |
| 73 | |
| 72 # silence output when running outside nose | 74 # silence output when running outside nose |
| 73 import tempfile | 75 import tempfile |
| 74 sys.stdout = tempfile.TemporaryFile() | 76 sys.stdout = tempfile.TemporaryFile() |
| 75 | 77 |
| 76 all = tests() | 78 all = tests() |
| 77 del all['test_util'] | |
| 78 | 79 |
| 79 args = [i.split('.py')[0].replace('-', '_') for i in args] | 80 args = [i.split('.py')[0].replace('-', '_') for i in args] |
| 80 | 81 |
| 81 if not args: | 82 if not args: |
| 82 check = lambda x: options.comprehensive or not comprehensive(x) | 83 check = lambda x: options.comprehensive or not comprehensive(x) |
