Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
lint fixes
  • Loading branch information
ShauryaDusht committed May 17, 2025
commit 9d6e590371f1a75dbae6eefbc23cc344644886cd
12 changes: 6 additions & 6 deletions Lib/test/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ProfileCLITests(unittest.TestCase):
def setUp(self):
Comment thread
ShauryaDusht marked this conversation as resolved.
self.temp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.temp_dir)

self.script_content = """\
def factorial(n):
if n <= 1:
Expand Down Expand Up @@ -219,17 +219,17 @@ def test_no_arguments(self):
def test_run_module(self):
module_name = "profilemod"
module_file = os.path.join(self.temp_dir, f"{module_name}.py")

with open(module_file, "w") as f:
f.write("print('Module executed')\n")
Comment thread
ShauryaDusht marked this conversation as resolved.

env = os.environ.copy()

python_path = self.temp_dir
if 'PYTHONPATH' in env:
python_path = os.pathsep.join([python_path, env['PYTHONPATH']])
env['PYTHONPATH'] = python_path

cmd = [sys.executable, '-m', 'profile', '-m', module_name]
proc = subprocess.Popen(
cmd,
Expand All @@ -240,7 +240,7 @@ def test_run_module(self):
)
stdout, stderr = proc.communicate()
returncode = proc.returncode

self.assertEqual(returncode, 0)
self.assertIn("Module executed", stdout)
self.assertIn("function calls", stdout)
Expand Down