Call portage._disable_legacy_globals() in order to ensure that we
[portage.git] / pym / portage / tests / runTests
1 #!/usr/bin/python
2 # runTests.py -- Portage Unit Test Functionality
3 # Copyright 2006 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License v2
5
6 import os, sys
7 import os.path as osp
8
9 # Insert our parent dir so we can do shiny import "tests"
10 # This line courtesy of Marienz and Pkgcore ;)
11 sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__)))))
12
13 import portage
14
15 # Ensure that we don't instantiate portage.settings, so that tests should
16 # work the same regardless of global configuration file state/existence.
17 portage._disable_legacy_globals()
18
19 import portage.tests as tests
20 from portage.const import PORTAGE_BIN_PATH
21 path = os.environ.get("PATH", "").split(":")
22 path = [x for x in path if x]
23 if not path or not os.path.samefile(path[0], PORTAGE_BIN_PATH):
24         path.insert(0, PORTAGE_BIN_PATH)
25         os.environ["PATH"] = ":".join(path)
26 del path
27
28
29 if __name__ == "__main__":
30         result = tests.main()
31         if not result.wasSuccessful():
32                 sys.exit(1)