-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tests more independent #5211
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
include requirements*.txt | ||
include src/toil/server/api_spec/workflow_execution_service.swagger.yaml | ||
include src/toil/test/cwl/colon_test_output_job.yaml | ||
include src/toil/test/cwl/conditional_wf.yaml | ||
include src/toil/test/cwl/mock_mpi/fake_mpi.yml | ||
include src/toil/test/docs/scripts/* | ||
include src/toil/test/utils/ABCWorkflowDebug/sleep.yaml | ||
include src/toil/test/utils/ABCWorkflowDebug/* | ||
recursive-include src/toil/test/ *.cwl | ||
recursive-include src/toil/test/ *.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools>=64", "setuptools_scm>=8"] | ||
build-backend = "setuptools.build_meta" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import atexit | ||
import datetime | ||
import logging | ||
import os | ||
|
@@ -28,8 +29,10 @@ | |
import zoneinfo | ||
from abc import ABCMeta, abstractmethod | ||
from collections.abc import Generator | ||
from contextlib import contextmanager | ||
from contextlib import ExitStack, contextmanager | ||
from importlib.resources import as_file, files | ||
from inspect import getsource | ||
from pathlib import Path | ||
from shutil import which | ||
from tempfile import mkstemp | ||
from textwrap import dedent | ||
|
@@ -52,6 +55,24 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_data(filename: str) -> str: | ||
"""Returns an absolute path for a file from this package.""" | ||
# normalizing path depending on OS or else it will cause problem when joining path | ||
filename = os.path.normpath(filename) | ||
filepath = None | ||
# import ipdb; ipdb.set_trace() | ||
try: | ||
file_manager = ExitStack() | ||
atexit.register(file_manager.close) | ||
traversable = files("toil") / filename | ||
filepath = file_manager.enter_context(as_file(traversable)) | ||
except ModuleNotFoundError: | ||
pass | ||
if not filepath or not os.path.isfile(filepath): | ||
filepath = Path(os.path.dirname(__file__)) / ".." / ".." / ".." / filename | ||
return str(filepath.resolve()) | ||
Comment on lines
+58
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should Should this maybe be a member of ToilTest so it doesn't need a separate import and more sensibly replaces Also, if the source tree is laid out so that a CWL file references another file nearby, and I There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, are we sure that the atexit trickery to defeat the context manager is worth it? I don't see many tests using more than 2 |
||
|
||
|
||
class ToilTest(unittest.TestCase): | ||
""" | ||
A common base class for Toil tests. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these implicitly scoped by what is in source control? Or will the wildcards potentially include things like editor swap files in the release?