FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-escpos/test/test_function_text.py at development · python-escpos/python-escpos · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-escpos
/
python-escpos
Public
Notifications
You must be signed in to change notification settings
Fork
316
Star
1.3k
Code
Issues
60
Pull requests
12
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-escpos
/
test
/
test_function_text.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (48 loc) · 1.58 KB
Breadcrumbs
python-escpos
/
test
/
test_function_text.py
Copy path
File metadata and controls
65 lines (48 loc) · 1.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
"""tests for the text printing function
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
pytest
import
mock
from
hypothesis
import
given
,
assume
import
hypothesis
.
strategies
as
st
from
escpos
.
printer
import
Dummy
def
get_printer
():
return
Dummy
(
magic_encode_args
=
{
'disabled'
:
True
,
'encoding'
:
'CP437'
})
@
given
(
text
=
st
.
text
())
def
test_text
(
text
):
"""Test that text() calls the MagicEncode object.
"""
instance
=
get_printer
()
instance
.
magic
.
write
=
mock
.
Mock
()
instance
.
text
(
text
)
instance
.
magic
.
write
.
assert_called_with
(
text
)
def
test_block_text
():
printer
=
get_printer
()
printer
.
block_text
(
"All the presidents men were eating falafel for breakfast."
,
font
=
'a'
)
assert
printer
.
output
==
\
b'All the presidents men were eating falafel
\n
for breakfast.'
def
test_textln
():
printer
=
get_printer
()
printer
.
textln
(
'hello, world'
)
assert
printer
.
output
==
b'hello, world
\n
'
def
test_textln_empty
():
printer
=
get_printer
()
printer
.
textln
()
assert
printer
.
output
==
b'
\n
'
def
test_ln
():
printer
=
get_printer
()
printer
.
ln
()
assert
printer
.
output
==
b'
\n
'
def
test_multiple_ln
():
printer
=
get_printer
()
printer
.
ln
(
3
)
assert
printer
.
output
==
b'
\n
\n
\n
'
Back
|
FazBrowse Home
|
New Git URL