Skip to content

Commit

Permalink
Fixing test discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Nov 18, 2015
1 parent a61e225 commit 8bd882b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ pep8ignore =

pep8maxlinelength = 120

norecursedirs = examples experiments
27 changes: 13 additions & 14 deletions tests/test_nohup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import os
import sys
import time
Expand All @@ -10,28 +11,26 @@
from plumbum.path.utils import delete
from plumbum._testtools import skip_on_windows

DIR = local.path(__file__).dirname

@skip_on_windows
class TestNohupLocal:
def read_file(self, filename):
assert filename in os.listdir('.')
with open(filename) as f:
return f.read()

@pytest.mark.usefixtures("testdir")
def test_slow(self):
with local.cwd(DIR):
delete('nohup.out')
sp = bash['slow_process.bash']
sp & NOHUP
time.sleep(.5)
assert self.read_file('slow_process.out') == 'Starting test\n1\n'
assert self.read_file('nohup.out') == '1\n'
time.sleep(1)
assert self.read_file('slow_process.out') == 'Starting test\n1\n2\n'
assert self.read_file('nohup.out') == '1\n2\n'
time.sleep(2)
delete('nohup.out', 'slow_process.out')
delete('nohup.out')
sp = bash['slow_process.bash']
sp & NOHUP
time.sleep(.5)
assert self.read_file('slow_process.out') == 'Starting test\n1\n'
assert self.read_file('nohup.out') == '1\n'
time.sleep(1)
assert self.read_file('slow_process.out') == 'Starting test\n1\n2\n'
assert self.read_file('nohup.out') == '1\n2\n'
time.sleep(2)
delete('nohup.out', 'slow_process.out')

def test_append(self):
delete('nohup.out')
Expand Down
19 changes: 8 additions & 11 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
else:
from plumbum.machines.paramiko_machine import ParamikoMachine

DIR = local.path(__file__).dirname


def strassert(one, two):
assert str(one) == str(two)

Expand Down Expand Up @@ -122,16 +119,16 @@ def test_glob(self):
assert "test_remote.py" in filenames
assert "slow_process.bash" in filenames

@pytest.mark.usefixtures("testdir")
def test_download_upload(self):
with self._connect() as rem:
with local.cwd(DIR):
rem.upload("test_remote.py", "/tmp")
r_ls = rem["ls"]
r_rm = rem["rm"]
assert "test_remote.py" in r_ls("/tmp").splitlines()
rem.download("/tmp/test_remote.py", "/tmp/test_download.txt")
r_rm("/tmp/test_remote.py")
r_rm("/tmp/test_download.txt")
rem.upload("test_remote.py", "/tmp")
r_ls = rem["ls"]
r_rm = rem["rm"]
assert "test_remote.py" in r_ls("/tmp").splitlines()
rem.download("/tmp/test_remote.py", "/tmp/test_download.txt")
r_rm("/tmp/test_remote.py")
r_rm("/tmp/test_download.txt")

def test_session(self):
with self._connect() as rem:
Expand Down

0 comments on commit 8bd882b

Please sign in to comment.