Skip to content

Commit

Permalink
Use 'file_path' attribute for Screenshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyWeeUsr committed Nov 4, 2018
1 parent acc9ea7 commit 57557fd
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions plyer/tests/test_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ def whereis_exe(binary):
return binary == 'xwd'

@staticmethod
def call(args):
def call(args, stdout):
'''
Mocked subprocess.call to check console parameters.
'''
assert len(args) == 2, len(args)
assert len(args) == 3, args
assert args[0] == 'xwd', args
assert args[1:] == ['-silent', '-root']
assert args[1:] == ['-silent', '-root'], args
assert stdout.name == join(
expanduser('~'), 'Pictures', 'screenshot.xwd'
), stdout.name
with open(stdout.name, 'w') as scr:
scr.write('')


class TestScreenshot(unittest.TestCase):
Expand Down Expand Up @@ -104,11 +109,8 @@ def test_screenshot_screencapture(self):
with patch(target='subprocess.call', new=MockedScreenCapture.call):
self.assertIsNone(scr.capture())

scr_path = join(
expanduser('~'), 'Pictures', 'screenshot.png'
)
self.assertTrue(exists(scr_path))
remove(scr_path)
self.assertTrue(exists(scr.file_path))
remove(scr.file_path)

@PlatformTest('linux')
def test_screenshot_xwd(self):
Expand All @@ -132,11 +134,8 @@ def test_screenshot_xwd(self):
with patch(target='subprocess.call', new=MockedXWD.call):
self.assertIsNone(scr.capture())

scr_path = join(
expanduser('~'), 'Pictures', 'screenshot.png'
)
self.assertTrue(exists(scr_path))
remove(scr_path)
self.assertTrue(exists(scr.file_path))
remove(scr.file_path)


if __name__ == '__main__':
Expand Down

0 comments on commit 57557fd

Please sign in to comment.