Skip to content

Commit

Permalink
Add PdfArrangerTest._start
Browse files Browse the repository at this point in the history
To factorize all PdfArrangerManager creation
  • Loading branch information
jeromerobert committed Dec 23, 2021
1 parent e8638cf commit b444361
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ def kill(self):

class PdfArrangerTest(unittest.TestCase):
LAST=False
def _start(self, args=None):
from dogtail.config import config
config.searchBackoffDuration = 1
self.__class__.pdfarranger = PdfArrangerManager(args)
# check that process is actually running
self.assertIsNone(self._process().poll())
self._app()
# Now let's go faster
config.searchBackoffDuration = 0.1

def _app(self):
# Cannot import at top level because of DBUS_SESSION_BUS_ADDRESS
from dogtail.tree import root
Expand Down Expand Up @@ -214,13 +224,7 @@ def tearDownClass(cls):

class TestBatch1(PdfArrangerTest):
def test_01_import_img(self):
self.__class__.pdfarranger = PdfArrangerManager(["data/screenshot.png"])
# check that process is actually running
self.assertIsNone(self._process().poll())
self._app()
from dogtail.config import config
# Now let's go faster
config.searchBackoffDuration = 0.1
self._start(["data/screenshot.png"])

def test_02_properties(self):
self._mainmenu("Edit Properties")
Expand Down Expand Up @@ -349,14 +353,7 @@ def test_11_quit(self):

class TestBatch2(PdfArrangerTest):
def test_01_open_empty(self):
from dogtail.config import config
config.searchBackoffDuration = 1
self.__class__.pdfarranger = PdfArrangerManager()
# check that process is actually running
self.assertIsNone(self._process().poll())
self._app()
# Now let's go faster
config.searchBackoffDuration = 0.1
self._start()

def test_02_import(self):
filechooser = self._import_file("tests/test.pdf")
Expand Down Expand Up @@ -400,17 +397,10 @@ class TestBatch3(PdfArrangerTest):
# Kill X11 after that batch
LAST=True
def test_01_open_encrypted(self):
from dogtail.config import config
config.searchBackoffDuration = 1
filename = os.path.join(self.__class__.tmp, "other_encrypted.pdf")
shutil.copyfile("tests/test_encrypted.pdf", filename)
self.__class__.pdfarranger = PdfArrangerManager([filename])
# check that process is actually running
self.assertIsNone(self._process().poll())
app = self._app()
# Now let's go faster
config.searchBackoffDuration = 0.1
dialog = app.child(roleName="dialog")
self._start([filename])
dialog = self._app().child(roleName="dialog")
passfield = dialog.child(roleName="password text")
passfield.text = "foobar"
dialog.child(name="OK").click()
Expand Down

0 comments on commit b444361

Please sign in to comment.