def it_can_recover_from_a_git_clean(self, in_example_dir, service_name): def assert_status(): assert_command( ('pgctl', 'status'), '''\ ● sleep: down ● tail: ready └─ pid: {PID}, {TIME} seconds ''', '', 0, norm=norm.pgctl, ) check_call(('pgctl', 'start', 'tail')) assert_status() # simulate a git-clean: blow everything away, create a fresh copy parent_dir = in_example_dir.join('..') with parent_dir.as_cwd(): in_example_dir.remove(rec=True) from testing import copy_example copy_example(service_name, parent_dir) assert_status()
def it_can_recover_from_a_git_clean(self, in_example_dir, service_name): def assert_status(): assert_command( ("pgctl-2015", "status"), """\ sleep: down tail: ready (pid {PID}) {TIME} seconds """, "", 0, norm=norm.pgctl, ) check_call(("pgctl-2015", "start", "tail")) assert_status() # simulate a git-clean: blow everything away, create a fresh copy parent_dir = in_example_dir.join("..") with parent_dir.as_cwd(): in_example_dir.remove(rec=True) from testing import copy_example copy_example(service_name, parent_dir) assert_status()
def in_example_dir(tmpdir, homedir, service_name): os.environ['HOME'] = homedir.strpath os.environ.pop('XDG_RUNTIME_DIR', None) example_dir = copy_example(service_name, tmpdir) with example_dir.as_cwd(): try: yield example_dir finally: # pytest does a chdir before calling cleanup handlers with example_dir.as_cwd(): # XXX: this is imported here so the blanking of # XDG_RUNTIME_DIR above affects this call from pgctl.cli import PgctlApp PgctlApp().stop()
def in_example_dir(tmpdir, homedir, service_name): os.environ['HOME'] = homedir.strpath # Also done by pytest.ini on session start, but is also done # here to prevent test pollution os.environ.pop('XDG_RUNTIME_DIR', None) example_dir = copy_example(service_name, tmpdir) with example_dir.as_cwd(): try: yield example_dir finally: # pytest does a chdir before calling cleanup handlers with example_dir.as_cwd(): PgctlApp().stop()