forked from github.com/blag
reformatted code
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# remove when we don't support py38 anymore
|
||||
from __future__ import annotations
|
||||
import time
|
||||
|
||||
import threading
|
||||
import time
|
||||
from argparse import Namespace
|
||||
|
||||
import pytest
|
||||
@@ -11,17 +12,17 @@ from blag import devserver
|
||||
|
||||
def test_get_last_modified(cleandir: str) -> None:
|
||||
# take initial time
|
||||
t1 = devserver.get_last_modified(['content'])
|
||||
t1 = devserver.get_last_modified(["content"])
|
||||
|
||||
# wait a bit, create a file and measure again
|
||||
time.sleep(0.1)
|
||||
with open('content/test', 'w') as fh:
|
||||
fh.write('boo')
|
||||
t2 = devserver.get_last_modified(['content'])
|
||||
with open("content/test", "w") as fh:
|
||||
fh.write("boo")
|
||||
t2 = devserver.get_last_modified(["content"])
|
||||
|
||||
# wait a bit and take time again
|
||||
time.sleep(0.1)
|
||||
t3 = devserver.get_last_modified(['content'])
|
||||
t3 = devserver.get_last_modified(["content"])
|
||||
|
||||
assert t2 > t1
|
||||
assert t2 == t3
|
||||
@@ -29,20 +30,20 @@ def test_get_last_modified(cleandir: str) -> None:
|
||||
|
||||
def test_autoreload_builds_immediately(args: Namespace) -> None:
|
||||
# create a dummy file that can be build
|
||||
with open('content/test.md', 'w') as fh:
|
||||
fh.write('boo')
|
||||
with open("content/test.md", "w") as fh:
|
||||
fh.write("boo")
|
||||
|
||||
t = threading.Thread(
|
||||
target=devserver.autoreload,
|
||||
args=(args,),
|
||||
daemon=True,
|
||||
)
|
||||
t0 = devserver.get_last_modified(['build'])
|
||||
t0 = devserver.get_last_modified(["build"])
|
||||
t.start()
|
||||
# try for 5 seconds...
|
||||
for i in range(5):
|
||||
time.sleep(1)
|
||||
t1 = devserver.get_last_modified(['build'])
|
||||
t1 = devserver.get_last_modified(["build"])
|
||||
print(t1)
|
||||
if t1 > t0:
|
||||
break
|
||||
@@ -60,16 +61,16 @@ def test_autoreload(args: Namespace) -> None:
|
||||
)
|
||||
t.start()
|
||||
|
||||
t0 = devserver.get_last_modified(['build'])
|
||||
t0 = devserver.get_last_modified(["build"])
|
||||
|
||||
# create a dummy file that can be build
|
||||
with open('content/test.md', 'w') as fh:
|
||||
fh.write('boo')
|
||||
with open("content/test.md", "w") as fh:
|
||||
fh.write("boo")
|
||||
|
||||
# try for 5 seconds to see if we rebuild once...
|
||||
for i in range(5):
|
||||
time.sleep(1)
|
||||
t1 = devserver.get_last_modified(['build'])
|
||||
t1 = devserver.get_last_modified(["build"])
|
||||
if t1 > t0:
|
||||
break
|
||||
assert t1 > t0
|
||||
|
||||
Reference in New Issue
Block a user