Bug 1744122 - Fix sys.path for comm_taskgraph unittests. r=mkmelin default tip
authorRob Lemley <rob@thunderbird.net>
Wed, 01 Dec 2021 18:12:48 +0000
changeset 34476 20b8d21ec757d068da293069db3cc5a481045d31
parent 34475 b076166eddeba62ff5df328913d2c051cd600b06
push id19439
push userthunderbird@calypsoblue.org
push dateFri, 03 Dec 2021 13:36:10 +0000
treeherdercomm-central@20b8d21ec757 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1744122, 1731160, 1731158
Bug 1744122 - Fix sys.path for comm_taskgraph unittests. r=mkmelin Fallout from bug 1731160 and 1731158. The virtual environment that mach python-test sets up doesn't pick up any of the python paths from comm/. This patch forces the issue. It seems like there should be a way to automatically import conftest.py, but I wasn't able to get that to work. Differential Revision: https://phabricator.services.mozilla.com/D132733
taskcluster/comm_taskgraph/test/__init__.py
taskcluster/comm_taskgraph/test/conftest.py
taskcluster/comm_taskgraph/test/test_optimization_strategies.py
taskcluster/comm_taskgraph/test/test_parameters.py
deleted file mode 100644
--- a/taskcluster/comm_taskgraph/test/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-#  This Source Code Form is subject to the terms of the Mozilla Public
-#  License, v. 2.0. If a copy of the MPL was not distributed with this
-#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from __future__ import absolute_import, print_function, unicode_literals
new file mode 100644
--- /dev/null
+++ b/taskcluster/comm_taskgraph/test/conftest.py
@@ -0,0 +1,7 @@
+import sys
+import os
+
+HERE = os.path.dirname(__file__)
+EXT_PATH = os.path.abspath(os.path.join(HERE, "..", ".."))
+
+sys.path.insert(0, EXT_PATH)
--- a/taskcluster/comm_taskgraph/test/test_optimization_strategies.py
+++ b/taskcluster/comm_taskgraph/test/test_optimization_strategies.py
@@ -6,17 +6,17 @@ from __future__ import absolute_import
 import hashlib
 from datetime import datetime
 from time import mktime
 
 import responses
 import pytest
 from mozunit import main
 
-# from responses import RequestsMock
+import conftest  # noqa: F401
 
 from comm_taskgraph.optimize import SkipSuiteOnly
 from gecko_taskgraph.optimize import registry
 from gecko_taskgraph.task import Task
 
 
 def generate_task():
     task = {}
--- a/taskcluster/comm_taskgraph/test/test_parameters.py
+++ b/taskcluster/comm_taskgraph/test/test_parameters.py
@@ -1,15 +1,16 @@
 #  This Source Code Form is subject to the terms of the Mozilla Public
 #  License, v. 2.0. If a copy of the MPL was not distributed with this
 #  file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import unittest
+import conftest  # noqa: F401
 
 import comm_taskgraph.parameters  # noqa: F401
 from gecko_taskgraph.parameters import Parameters
 from mozunit import main
 
 
 class TestCommParameters(unittest.TestCase):