Commit f1c5a72c authored by MinchinWeb's avatar MinchinWeb

Provide `mock` and `shutil.get_terminal_size` for testing on PyPy 3.

parent 650a420c
...@@ -32,6 +32,16 @@ Simply install with: ...@@ -32,6 +32,16 @@ Simply install with:
(not supported for Python 3.2). (not supported for Python 3.2).
* [prompt-toolkit][6] : For topydo's _prompt_ mode, which offers a shell-like * [prompt-toolkit][6] : For topydo's _prompt_ mode, which offers a shell-like
interface with auto-completion. interface with auto-completion.
* [arrow][8] : Used to turn dates into a human readable version.
* [backports.shutil_get_terminal_size][9] : Used to determine your terminal
window size. This function was
added to the standard library in
Python 3.3 and so is only
required in older versions of
Python.
* [python-dateutil][10]: A dependency of *arrow*.
* [mock][11] : Used for testing. This was added to the standard
library in Python 3.3.
Demo Demo
---- ----
...@@ -46,3 +56,7 @@ Demo ...@@ -46,3 +56,7 @@ Demo
[5]: https://raw.githubusercontent.com/bram85/topydo/master/doc/topydo.gif [5]: https://raw.githubusercontent.com/bram85/topydo/master/doc/topydo.gif
[6]: https://github.com/jonathanslenders/python-prompt-toolkit [6]: https://github.com/jonathanslenders/python-prompt-toolkit
[7]: https://github.com/collective/icalendar [7]: https://github.com/collective/icalendar
[8]: https://github.com/crsmithdev/arrow
[9]: https://github.com/chrippa/backports.shutil_get_terminal_size
[10]: https://dateutil.readthedocs.org/
[11]: https://github.com/testing-cabal/mock
...@@ -33,9 +33,11 @@ setup( ...@@ -33,9 +33,11 @@ setup(
], ],
extras_require = { extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'], ':sys_platform=="win32"': ['colorama>=0.2.5'],
':python_version=="3.2"': ['backports.shutil_get_terminal_size>=1.0.0'],
'ical': ['icalendar'], 'ical': ['icalendar'],
'prompt-toolkit': ['prompt-toolkit >= 0.53'], 'prompt-toolkit': ['prompt-toolkit >= 0.53'],
'test': ['coverage', 'freezegun', 'green', ], 'test': ['coverage', 'freezegun', 'green', ],
'test:python_version=="3.2"': ['mock'],
}, },
entry_points= { entry_points= {
'console_scripts': ['topydo = topydo.cli.UILoader:main'], 'console_scripts': ['topydo = topydo.cli.UILoader:main'],
......
...@@ -18,13 +18,20 @@ import codecs ...@@ -18,13 +18,20 @@ import codecs
import re import re
import unittest import unittest
from collections import namedtuple from collections import namedtuple
from unittest import mock
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist from test.facilities import load_file_to_todolist
from topydo.commands.ListCommand import ListCommand from topydo.commands.ListCommand import ListCommand
from topydo.lib.Config import config from topydo.lib.Config import config
# We're searching for 'mock'
# 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2
# pylint: disable=no-name-in-module
try:
from unittest import mock
except ImportError:
import mock
class ListCommandTest(CommandTest): class ListCommandTest(CommandTest):
def setUp(self): def setUp(self):
......
...@@ -25,12 +25,14 @@ from topydo.commands.ListCommand import ListCommand ...@@ -25,12 +25,14 @@ from topydo.commands.ListCommand import ListCommand
from topydo.lib.Config import config from topydo.lib.Config import config
# We're searching for 'mock' # We're searching for 'mock'
# 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2
# pylint: disable=no-name-in-module # pylint: disable=no-name-in-module
try: try:
from unittest import mock from unittest import mock
except ImportError: except ImportError:
import mock import mock
@freeze_time("2015, 11, 06") @freeze_time("2015, 11, 06")
class ListFormatTest(CommandTest): class ListFormatTest(CommandTest):
def setUp(self): def setUp(self):
...@@ -43,7 +45,7 @@ class ListFormatTest(CommandTest): ...@@ -43,7 +45,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -60,7 +62,7 @@ class ListFormatTest(CommandTest): ...@@ -60,7 +62,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -77,7 +79,7 @@ class ListFormatTest(CommandTest): ...@@ -77,7 +79,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -94,7 +96,7 @@ class ListFormatTest(CommandTest): ...@@ -94,7 +96,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -111,7 +113,7 @@ class ListFormatTest(CommandTest): ...@@ -111,7 +113,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -129,7 +131,7 @@ class ListFormatTest(CommandTest): ...@@ -129,7 +131,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| D Bar @Context1 +Project2 (3 months ago, due a month ago, started a month ago) result = """| 1| D Bar @Context1 +Project2 (3 months ago, due a month ago, started a month ago)
| 2| Z Lorem ipsum dolorem sit amet. Red @f... lazy:bar (just now, due in 2 days, starts in a day) | 2| Z Lorem ipsum dolorem sit amet. Red @f... lazy:bar (just now, due in 2 days, starts in a day)
| 3| C Foo @Context2 Not@Context +Project1 Not+Project (4 months ago) | 3| C Foo @Context2 Not@Context +Project1 Not+Project (4 months ago)
| 4| C Baz @Context1 +Project1 key:value | 4| C Baz @Context1 +Project1 key:value
...@@ -146,7 +148,7 @@ class ListFormatTest(CommandTest): ...@@ -146,7 +148,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| D Bar @Context1 +Project2 (due a month ago, started a month ago) result = """| 1| D Bar @Context1 +Project2 (due a month ago, started a month ago)
| 2| Z Lorem ipsum dolorem sit amet. Red @fox +jumped... lazy:bar (due in 2 days, starts in a day) | 2| Z Lorem ipsum dolorem sit amet. Red @fox +jumped... lazy:bar (due in 2 days, starts in a day)
| 3| C Foo @Context2 Not@Context +Project1 Not+Project | 3| C Foo @Context2 Not@Context +Project1 Not+Project
| 4| C Baz @Context1 +Project1 key:value | 4| C Baz @Context1 +Project1 key:value
...@@ -163,7 +165,7 @@ class ListFormatTest(CommandTest): ...@@ -163,7 +165,7 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""2015-08-31 2015-09-30 2015-09-29 result = """2015-08-31 2015-09-30 2015-09-29
2015-11-06 2015-11-08 2015-11-07 2015-11-06 2015-11-08 2015-11-07
2015-07-12 2015-07-12
...@@ -180,7 +182,7 @@ x 2014-12-12 ...@@ -180,7 +182,7 @@ x 2014-12-12
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""3 months ago | a month ago | a month ago | result = """3 months ago | a month ago | a month ago |
just now | in 2 days | in a day | just now | in 2 days | in a day |
4 months ago | | | 4 months ago | | |
| | | | | |
...@@ -194,7 +196,7 @@ just now | in 2 days | in a day | ...@@ -194,7 +196,7 @@ just now | in 2 days | in a day |
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""|1| result = """|1|
|2| lazy:bar |2| lazy:bar
|3| |3|
|4| key:value |4| key:value
...@@ -208,7 +210,7 @@ just now | in 2 days | in a day | ...@@ -208,7 +210,7 @@ just now | in 2 days | in a day |
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| due:2015-09-30 t:2015-09-29 result = """| 1| due:2015-09-30 t:2015-09-29
| 2| due:2015-11-08 lazy:bar t:2015-11-07 | 2| due:2015-11-08 lazy:bar t:2015-11-07
| 3| | 3|
| 4| key:value | 4| key:value
...@@ -222,7 +224,7 @@ just now | in 2 days | in a day | ...@@ -222,7 +224,7 @@ just now | in 2 days | in a day |
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| % result = """| 1| %
| 2| % | 2| %
| 3| % | 3| %
| 4| % | 4| %
...@@ -236,7 +238,7 @@ just now | in 2 days | in a day | ...@@ -236,7 +238,7 @@ just now | in 2 days | in a day |
self.todolist, self.out, self.error) self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -252,7 +254,7 @@ just now | in 2 days | in a day | ...@@ -252,7 +254,7 @@ just now | in 2 days | in a day |
self.todolist, self.out, self.error) self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
""" """
...@@ -262,7 +264,7 @@ just now | in 2 days | in a day | ...@@ -262,7 +264,7 @@ just now | in 2 days | in a day |
command = ListCommand(["-x", "-F", "%c"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%c"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""2015-08-31 result = """2015-08-31
2015-11-06 2015-11-06
2015-07-12 2015-07-12
...@@ -275,7 +277,7 @@ just now | in 2 days | in a day | ...@@ -275,7 +277,7 @@ just now | in 2 days | in a day |
command = ListCommand(["-x", "-F", "%C"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%C"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""3 months ago result = """3 months ago
just now just now
4 months ago 4 months ago
...@@ -288,7 +290,7 @@ just now ...@@ -288,7 +290,7 @@ just now
command = ListCommand(["-x", "-F", "%d"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%d"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""2015-09-30 result = """2015-09-30
2015-11-08 2015-11-08
...@@ -301,7 +303,7 @@ just now ...@@ -301,7 +303,7 @@ just now
command = ListCommand(["-x", "-F", "%D"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%D"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""a month ago result = """a month ago
in 2 days in 2 days
...@@ -314,7 +316,7 @@ in 2 days ...@@ -314,7 +316,7 @@ in 2 days
command = ListCommand(["-x", "-F", "%h"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%h"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""due a month ago, started a month ago result = """due a month ago, started a month ago
due in 2 days, starts in a day due in 2 days, starts in a day
...@@ -327,7 +329,7 @@ due in 2 days, starts in a day ...@@ -327,7 +329,7 @@ due in 2 days, starts in a day
command = ListCommand(["-x", "-F", "%H"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%H"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""3 months ago, due a month ago, started a month ago result = """3 months ago, due a month ago, started a month ago
just now, due in 2 days, starts in a day just now, due in 2 days, starts in a day
4 months ago 4 months ago
...@@ -340,7 +342,7 @@ just now, due in 2 days, starts in a day ...@@ -340,7 +342,7 @@ just now, due in 2 days, starts in a day
command = ListCommand(["-x", "-F", "%i"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%i"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""1 result = """1
2 2
3 3
4 4
...@@ -353,7 +355,7 @@ just now, due in 2 days, starts in a day ...@@ -353,7 +355,7 @@ just now, due in 2 days, starts in a day
command = ListCommand(["-x", "-F", "%I"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%I"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" 1 result = """ 1
2 2
3 3
4 4
...@@ -366,7 +368,7 @@ just now, due in 2 days, starts in a day ...@@ -366,7 +368,7 @@ just now, due in 2 days, starts in a day
command = ListCommand(["-x", "-F", "%k"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%k"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" result = """
lazy:bar lazy:bar
key:value key:value
...@@ -379,7 +381,7 @@ date:2014-12-12 ...@@ -379,7 +381,7 @@ date:2014-12-12
command = ListCommand(["-x", "-F", "%K"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%K"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""due:2015-09-30 t:2015-09-29 result = """due:2015-09-30 t:2015-09-29
due:2015-11-08 lazy:bar t:2015-11-07 due:2015-11-08 lazy:bar t:2015-11-07
key:value key:value
...@@ -392,7 +394,7 @@ date:2014-12-12 ...@@ -392,7 +394,7 @@ date:2014-12-12
command = ListCommand(["-x", "-F", "%p"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%p"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""D result = """D
Z Z
C C
C C
...@@ -421,7 +423,7 @@ Completed but with ...@@ -421,7 +423,7 @@ Completed but with
command = ListCommand(["-x", "-F", "%S"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%S"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""Bar @Context1 +Project2 result = """Bar @Context1 +Project2
Lorem ipsum dolorem sit amet. Red @fox +jumped... Lorem ipsum dolorem sit amet. Red @fox +jumped...
Foo @Context2 Not@Context +Project1 Not+Project Foo @Context2 Not@Context +Project1 Not+Project
Baz @Context1 +Project1 Baz @Context1 +Project1
...@@ -434,7 +436,7 @@ Completed but with ...@@ -434,7 +436,7 @@ Completed but with
command = ListCommand(["-x", "-F", "%t"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%t"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""2015-09-29 result = """2015-09-29
2015-11-07 2015-11-07
...@@ -447,7 +449,7 @@ Completed but with ...@@ -447,7 +449,7 @@ Completed but with
command = ListCommand(["-x", "-F", "%T"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%T"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""a month ago result = """a month ago
in a day in a day
...@@ -460,7 +462,7 @@ in a day ...@@ -460,7 +462,7 @@ in a day
command = ListCommand(["-x", "-F", "%x"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" result = """
...@@ -473,7 +475,7 @@ x 2014-12-12 ...@@ -473,7 +475,7 @@ x 2014-12-12
command = ListCommand(["-x", "-F", "%X"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%X"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" result = """
...@@ -486,7 +488,7 @@ x 11 months ago ...@@ -486,7 +488,7 @@ x 11 months ago
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%{{}p{}}"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%{{}p{}}"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""{C} result = """{C}
{C} {C}
{D} {D}
{Z} {Z}
...@@ -499,7 +501,7 @@ x 11 months ago ...@@ -499,7 +501,7 @@ x 11 months ago
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%{\%p}p{\%p}"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%{\%p}p{\%p}"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""%pC%p result = """%pC%p
%pC%p %pC%p
%pD%p %pD%p
%pZ%p %pZ%p
...@@ -512,7 +514,7 @@ x 11 months ago ...@@ -512,7 +514,7 @@ x 11 months ago
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p%p"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p%p"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""CC result = """CC
CC CC
DD DD
ZZ ZZ
...@@ -527,7 +529,7 @@ ZZ ...@@ -527,7 +529,7 @@ ZZ
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p{ } %{ }p"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p{ } %{ }p"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""C C result = """C C
C C C C
D D D D
Z Z Z Z
...@@ -543,7 +545,7 @@ Z Z ...@@ -543,7 +545,7 @@ Z Z
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p{ } %{ }p"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p{ } %{ }p"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""C C result = """C C
C C C C
D D D D
Z Z Z Z
...@@ -558,7 +560,7 @@ Z Z ...@@ -558,7 +560,7 @@ Z Z
command = ListCommand(["-x", "-s", "desc:priority", "-F", " %{ }p"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", " %{ }p"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" C result = """ C
C C
D D
Z Z
...@@ -574,7 +576,7 @@ Z Z ...@@ -574,7 +576,7 @@ Z Z
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%&"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%&"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" result = """
...@@ -591,7 +593,7 @@ Z Z ...@@ -591,7 +593,7 @@ Z Z
command = ListCommand(["-x", "-s", "desc:priority", "-F", "%"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-s", "desc:priority", "-F", "%"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" result = """
...@@ -608,7 +610,7 @@ Z Z ...@@ -608,7 +610,7 @@ Z Z
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -624,7 +626,7 @@ Z Z ...@@ -624,7 +626,7 @@ Z Z
command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %S\\t%K"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %S\\t%K"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u"""| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
...@@ -641,7 +643,7 @@ Z Z ...@@ -641,7 +643,7 @@ Z Z
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" | 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """ | 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @... due:2015-11-08 lazy:bar t:2015-11-07 | 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project | 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value | 4| (C) Baz @Context1 +Project1 key:value
......
...@@ -23,6 +23,12 @@ import re ...@@ -23,6 +23,12 @@ import re
from collections import namedtuple from collections import namedtuple
from datetime import date from datetime import date
# shutil.get_terminal_size was added to the standard library in Python 3.3
try:
from shutil import get_terminal_size as _get_terminal_size # pylint: disable=no-name-in-module
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size # pylint: disable=import-error
def date_string_to_date(p_date): def date_string_to_date(p_date):
""" """
...@@ -54,15 +60,14 @@ def escape_ansi(p_string): ...@@ -54,15 +60,14 @@ def escape_ansi(p_string):
escape_ansi.pattern = re.compile(r'\x1b[^m]*m') escape_ansi.pattern = re.compile(r'\x1b[^m]*m')
def get_terminal_size(): def get_terminal_size():
""" """
Try to determine terminal size at run time. If that is not possible, Try to determine terminal size at run time. If that is not possible,
returns the default size of 80x24. returns the default size of 80x24.
""" """
from shutil import get_terminal_size # pylint: disable=no-name-in-module
try: try:
sz = get_terminal_size() sz = _get_terminal_size()
except ValueError: except ValueError:
""" """
This can result from the 'underlying buffer being detached', which This can result from the 'underlying buffer being detached', which
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment