Skip to content

Commit

Permalink
Tests: Rename variables test*
Browse files Browse the repository at this point in the history
Prepare for pytest - rename variables; this is required
because pytest collects tests from classes and functions `test*`.
  • Loading branch information
phdru authored and ljmccarthy committed Jul 4, 2018
1 parent 80de1fc commit 65a66c5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions tests/test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from utils import *
from fsmonitor import *

w = test.add_dir_watch(tempdir)
touch(testpath("x"))
remove(testpath("x"))
w = fsm_test.add_dir_watch(tempdir)
touch(get_testpath("x"))
remove(get_testpath("x"))

time.sleep(0.1)

assert test.event_happened(FSEvent.Create, "x")
assert test.event_happened(FSEvent.Delete, "x")
assert fsm_test.event_happened(FSEvent.Create, "x")
assert fsm_test.event_happened(FSEvent.Delete, "x")
12 changes: 6 additions & 6 deletions tests/test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from utils import *
from fsmonitor import *

w = test.add_dir_watch(tempdir)
touch(testpath("x"))
test.remove_watch(w)
remove(testpath("x"))
w = fsm_test.add_dir_watch(tempdir)
touch(get_testpath("x"))
fsm_test.remove_watch(w)
remove(get_testpath("x"))

time.sleep(0.1)

assert test.event_happened(FSEvent.Create, "x")
assert not test.event_happened(FSEvent.Delete, "x")
assert fsm_test.event_happened(FSEvent.Create, "x")
assert not fsm_test.event_happened(FSEvent.Delete, "x")
2 changes: 1 addition & 1 deletion tests/test3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fsmonitor import *

try:
test.add_dir_watch("/this/path/does/not/exist")
fsm_test.add_dir_watch("/this/path/does/not/exist")
except FSMonitorError as e:
assert e.errno == errno.ENOENT
else:
Expand Down
10 changes: 5 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from fsmonitor import FSMonitorThread

class TestFSMonitor(object):
class _TestFSMonitor(object):
def __init__(self):
self.monitor = FSMonitorThread(self.__callback)
self._lock = threading.Lock()
Expand Down Expand Up @@ -34,7 +34,7 @@ def event_happened(self, action=None, name=None, path=None):
return True
return False

test = TestFSMonitor()
fsm_test = _TestFSMonitor()

def mkdir(path):
try:
Expand Down Expand Up @@ -62,19 +62,19 @@ def truncate(path):
else:
tempdir = "/tmp"

def testpath(*args):
def get_testpath(*args):
return os.path.join(tempdir, *args)

tempdir = os.path.join(tempdir, "fsmonitor-test")
shutil.rmtree(tempdir, ignore_errors=True)
mkdir(tempdir)

__all__ = (
"test",
"fsm_test",
"mkdir",
"remove",
"touch",
"truncate",
"tempdir",
"testpath"
"get_testpath"
)

0 comments on commit 65a66c5

Please sign in to comment.