# Path: tests/utils.py
# class temporary_directory(object):
# 
#     def __init__(self, prefix=''):
#         self.prefix = prefix
#         self.delete = False
# 
#     def __enter__(self):
#         self.original_cwd = os.getcwd()
#         self.temp_path = tempfile.mkdtemp(prefix=self.prefix)
#         os.chdir(self.temp_path)
#         return self.temp_path
# 
#     def __exit__(self, exc_type, exc_value, traceback):
#         if self.delete and self.temp_path and os.path.exists(self.temp_path):
#             print('Deleting temporary testind directory: %s' % self.temp_path)
#             shutil.rmtree(self.temp_path)
#         if self.original_cwd and os.path.exists(self.original_cwd):
#             os.chdir(self.original_cwd)


import os
import shutil
from ..utils import temporary_directory



class workspace_factory(temporary_directory):

    def __init__(self, source_space='src', prefix=''):
        super(workspace_factory, self).__init__(prefix=prefix)
        self.source_space = source_space

    def __enter__(self):
        self.temporary_directory = super(workspace_factory, self).__enter__()

# Path: tests/utils.py
# class temporary_directory(object):
# 
#     def __init__(self, prefix=''):
#         self.prefix = prefix
#         self.delete = False
# 
#     def __enter__(self):
#         self.original_cwd = os.getcwd()
#         self.temp_path = tempfile.mkdtemp(prefix=self.prefix)
#         os.chdir(self.temp_path)
#         return self.temp_path
# 
#     def __exit__(self, exc_type, exc_value, traceback):
#         if self.delete and self.temp_path and os.path.exists(self.temp_path):
#             print('Deleting temporary testind directory: %s' % self.temp_path)
#             shutil.rmtree(self.temp_path)
#         if self.original_cwd and os.path.exists(self.original_cwd):
#             os.chdir(self.original_cwd)


# Path: tests/system/workspace_factory.py
import os
import shutil
from ..utils import temporary_directory




class workspace_factory(temporary_directory):

    def __init__(self, source_space='src', prefix=''):
        super(workspace_factory, self).__init__(prefix=prefix)
        self.source_space = source_space

    def __enter__(self):
        self.temporary_directory = super(workspace_factory, self).__enter__()

        self.workspace_factory = WorkspaceFactory(self.temporary_directory, self.source_space)