Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 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
24 changes: 24 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
from pathlib import Path
from unittest import TestCase

import pytest


@pytest.fixture
def isolated_test_env(tmp_path):
config_path = Path(__file__).resolve().parent.parent.parent / "zowe.config.json"

config_file = tmp_path / "zowe.config.json"
config_file.write_text(config_path.read_text())

return {
"config_path": config_path,
"config_file": config_file
}

class TestIsolatedEnv(unittest.TestCase):
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inheriting from unittest.TestCase while using pytest fixtures may lead to unexpected test collection behavior; consider defining TestIsolatedEnv as a plain class or using pytest’s xunit setup hooks instead.

Suggested change
class TestIsolatedEnv(unittest.TestCase):
class TestIsolatedEnv:

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider this comment as we don't want this to negatively impact test collection behavior. Maybe we can pursue those xunit setup hooks.

"""Base class for isolated test environments."""
@pytest.fixture(autouse=True)
def _setup_test_env(self, isolated_test_env):
self.isolated_test_env = isolated_test_env
Comment on lines +20 to +24
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autouse fixtures defined inside a TestCase subclass may not be applied as intended. Move this fixture to the module scope (top level in conftest.py) for pytest to recognize it properly.

Suggested change
class TestIsolatedEnv(unittest.TestCase):
"""Base class for isolated test environments."""
@pytest.fixture(autouse=True)
def _setup_test_env(self, isolated_test_env):
self.isolated_test_env = isolated_test_env
@pytest.fixture(autouse=True)
def _setup_test_env(isolated_test_env):
"""Automatically set up the isolated test environment."""
return isolated_test_env
class TestIsolatedEnv(unittest.TestCase):
"""Base class for isolated test environments."""
def setUp(self):
self.isolated_test_env = _setup_test_env(isolated_test_env)

Copilot uses AI. Check for mistakes.
9 changes: 9 additions & 0 deletions tests/integration/test_integration_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Test isolated environment setup for integration tests."""

def test_isolated_env_does_not_touch_real_home(isolated_test_env):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does this actually verify that the environment does not touch the "real home"?
  • When you mean "real home," are you referring to the user's home directory? or ZOWE_CLI_HOME?

config_path = isolated_test_env["config_path"]
config_file = isolated_test_env["config_file"]

assert config_path.exists(), f"Missing config at {config_path}"
assert config_file.exists()
assert "profiles" in config_file.read_text()
5 changes: 2 additions & 3 deletions tests/integration/test_zos_console.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Integration tests for the Zowe Python SDK z/OS Console package."""

import unittest

from integration.conftest import TestIsolatedEnv
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zos_console_for_zowe_sdk import Console


class TestConsoleIntegration(unittest.TestCase):
class TestConsoleIntegration(TestIsolatedEnv):
"""Console class integration tests."""

def setUp(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_zos_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import json
import os
import unittest

import urllib3
from integration.conftest import TestIsolatedEnv
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zos_files_for_zowe_sdk import Files
from zowe.zos_files_for_zowe_sdk.response.datasets import (
Expand All @@ -17,7 +17,7 @@
SAMPLE_JCL_FIXTURE_PATH = os.path.join(FIXTURES_PATH, "sample.jcl")


class TestFilesIntegration(unittest.TestCase):
class TestFilesIntegration(TestIsolatedEnv):
"""Files class integration tests."""

def setUp(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_zos_jobs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Integration tests for the Zowe Python SDK z/OS Jobs package."""
import json
import os
import unittest

from integration.conftest import TestIsolatedEnv
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zos_jobs_for_zowe_sdk import Jobs

Expand All @@ -11,7 +11,7 @@
SAMPLE_JCL_FIXTURE_PATH = os.path.join(FIXTURES_PATH, "sample.jcl")


class TestJobsIntegration(unittest.TestCase):
class TestJobsIntegration(TestIsolatedEnv):
"""Jobs class integration tests."""

def setUp(self):
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/test_zos_tso.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Integration tests for the Zowe Python SDK z/OS Tso package."""

import unittest

from integration.conftest import TestIsolatedEnv
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zos_tso_for_zowe_sdk import Tso
from zowe.zos_tso_for_zowe_sdk.response import IssueResponse


class TestTsoIntegration(unittest.TestCase):
class TestTsoIntegration(TestIsolatedEnv):
"""Tso class integration tests."""

def setUp(self):
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/test_zosmf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Integration tests for the Zowe Python SDK z/OSMF package."""

import unittest

from integration.conftest import TestIsolatedEnv
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zosmf_for_zowe_sdk import Zosmf
from zowe.zosmf_for_zowe_sdk.response import ZosmfResponse


class TestZosmfIntegration(unittest.TestCase):
class TestZosmfIntegration(TestIsolatedEnv):
"""Zosmf class integration tests."""

def setUp(self):
Expand Down