Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""Test configuration."""

import os
import sys

import pytest


@pytest.fixture(autouse=True, scope="session")
def add_cwd_to_syspath():
"""Ensure the current working directory is in sys.path.

CFFI and ffcx.main compile/generate files into CWD by default. Without
this, importlib.import_module cannot find those files when ``pytest``
is invoked from a directory that is not already on sys.path
(e.g. the project root rather than the test/ subdirectory).
"""
cwd = os.getcwd()
if cwd not in sys.path:
sys.path.append(cwd)


@pytest.fixture(scope="module")
def compile_args():
"""Compiler arguments."""
Expand Down
Loading