File: helpers_for_tests.py

package info (click to toggle)
python-mcstasscript 0.0.46%2Bgit20250402111921.bfa5a26-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,440 kB
  • sloc: python: 13,421; makefile: 14
file content (13 lines) | stat: -rw-r--r-- 345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
import os

class WorkInTestDir:
    """
    Simple class that enables working in test directory
    """
    def __enter__(self):
        self.current_work_dir = os.getcwd()
        os.chdir(os.path.dirname(os.path.abspath(__file__)))
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        os.chdir(self.current_work_dir)