Skip to content

Commit

Permalink
light: add workaround for running light tests in VSCode terminal
Browse files Browse the repository at this point in the history
See this issue for details: microsoft/node-pty#499

Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com>
Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com>
  • Loading branch information
OverOrion and alltilla committed Oct 31, 2023
1 parent 08d2a6d commit d2b8f3d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/light/functional_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

logger = logging.getLogger(__name__)

base_number_of_open_fds = 0


def calculate_report_file_path(working_dir):
return Path(working_dir, "testcase.reportlog")
Expand All @@ -55,6 +57,11 @@ def pytest_runtest_setup(item):
os.chdir(working_dir)


def pytest_sessionstart(session):
global base_number_of_open_fds
base_number_of_open_fds = len(psutil.Process().open_files())


def light_extra_files(target_dir):
if "LIGHT_EXTRA_FILES" in os.environ:
for f in os.environ["LIGHT_EXTRA_FILES"].split(":"):
Expand All @@ -64,7 +71,9 @@ def light_extra_files(target_dir):

@pytest.fixture(autouse=True)
def setup(request):
assert len(psutil.Process().open_files()) == 1, "Previous testcase has unclosed opened fds"
global base_number_of_open_fds
number_of_open_fds = len(psutil.Process().open_files())
assert base_number_of_open_fds + 1 == number_of_open_fds, "Previous testcase has unclosed opened fds"
assert len(psutil.Process().connections(kind="inet")) == 0, "Previous testcase has unclosed opened sockets"
testcase_parameters = request.getfixturevalue("testcase_parameters")

Expand Down

0 comments on commit d2b8f3d

Please sign in to comment.