File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ import shutil
3+ import tempfile
14import unittest
25from unittest .mock import MagicMock , patch
36
@@ -9,6 +12,22 @@ class TestMain(unittest.TestCase):
912 Unit tests for the main functionality of CodeEntropy.
1013 """
1114
15+ def setUp (self ):
16+ """
17+ Set up a temporary directory as the working directory before each test.
18+ """
19+ self .test_dir = tempfile .mkdtemp (prefix = "CodeEntropy_" )
20+ self ._orig_dir = os .getcwd ()
21+ os .chdir (self .test_dir )
22+
23+ def tearDown (self ):
24+ """
25+ Clean up by removing the temporary directory and restoring the original working
26+ directory.
27+ """
28+ os .chdir (self ._orig_dir )
29+ shutil .rmtree (self .test_dir )
30+
1231 @patch ("CodeEntropy.main.sys.exit" )
1332 @patch ("CodeEntropy.main.RunManager" )
1433 def test_main_successful_run (self , mock_RunManager , mock_exit ):
You can’t perform that action at this time.
0 commit comments