Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework bitmap image rendering simulation #63

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2147966
remove private methods that don't change test outcome from mock classes
ArchibaldBienetre Jan 9, 2020
e171044
remove unneeded test-only guards from time when curses was still WIP
ArchibaldBienetre Jan 9, 2020
f006b1c
merge _cursor_XXX and move_YYY functions in mock classes
ArchibaldBienetre Jan 9, 2020
616d606
Merge remote-tracking branch 'origin/feature/delete' into feature/rew…
ArchibaldBienetre Jan 9, 2020
7519a01
fix deletion based on curses
ArchibaldBienetre Jan 14, 2020
6f889fa
fix some PyCharm warnings
ArchibaldBienetre Jan 14, 2020
edd6156
switch MicrostepBasedErikaMock to curses; move common code up to Abst…
ArchibaldBienetre Jan 14, 2020
bb46b44
test curses with every pre-existing check
ArchibaldBienetre Jan 14, 2020
5f58b81
enable HTML test results reporting
ArchibaldBienetre Jan 14, 2020
b7424e6
fix tests (encoding issue)
ArchibaldBienetre Jan 14, 2020
24ccce9
add piping scenario to manual tests
ArchibaldBienetre Jan 14, 2020
695e344
remove redundant "encode('UTF-')" - seems to be the default
ArchibaldBienetre Jan 14, 2020
e9bf490
adjust HTML test output config + ignores
ArchibaldBienetre Jan 14, 2020
57dd73b
fix manual tests
ArchibaldBienetre Jan 14, 2020
2872f3c
Merge remote-tracking branch 'origin/master' into feature/rework-bitm…
ArchibaldBienetre Jan 15, 2020
d712cdc
change erika mock default parameter: do not throw when overprinting
ArchibaldBienetre Jan 15, 2020
8de2731
fix a typo + PyCharm warning
ArchibaldBienetre Jan 15, 2020
767c090
fix delete for curses
ArchibaldBienetre Jan 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
test_output/
htmlcov/
.tox/
.nox/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ python:
install:
- pip install -r test_requirements.txt
script:
- pytest --cov=erika tests/ --cov-report=html -m 'not hardware'
- pytest --cov=erika tests/ --cov-report=html --html=test_output/report.html -m 'not hardware'
20 changes: 9 additions & 11 deletions erika/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ def print_ascii_art(args):
renderer = ErikaImageRenderer(erika, strategy_string)
renderer.render_file(file_path)
finally:
erika.wait_for_user_if_simulated()
if erika:
erika.wait_for_user_if_simulated()

# Do a proper shutdown even in case of exception - or curses settings may make the current terminal unusable.
# I googled - it's okay to call __exit__ directly ( https://stackoverflow.com/a/26635947/1143126 )
erika.__exit__()
# Do a proper shutdown even in case of exception - or curses settings may make the current terminal unusable.
# I googled - it's okay to call __exit__ directly ( https://stackoverflow.com/a/26635947/1143126 )
erika.__exit__()


def run_tic_tac_toe(args):
Expand All @@ -137,18 +138,15 @@ def get_erika_for_given_args(args, is_character_based=False):
if is_dry_run:
if is_character_based or not 'file' in args:
# using low size just so it fits on the screen well - does not reflect the paper dimensions that Erika supports
erika = CharacterBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY,
exception_if_overprinted=False)
erika = CharacterBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY)
else:
# a bit hacky, as I'm mirroring behavior from ErikaImageRenderer - this kindof goes against the now-beautiful architecture :(
try:
# hacky: use exception to determine image type
image_for_provoking_exception = WrappedImage(args.file)
erika = MicrostepBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, output_after_each_step=True,
delay_after_each_step=DRY_RUN_DELAY, exception_if_overprinted=False)
erika = MicrostepBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY)
except NotAnImageException:
erika = CharacterBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY,
exception_if_overprinted=False)
erika = CharacterBasedErikaMock(DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY)
Comment on lines -140 to +149

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sane defaults would be nice here, so that parameter-less ctor.
Limiting the hight might not make much sense, because we use endless paper with hardware.

Copy link
Author

@ArchibaldBienetre ArchibaldBienetre Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed:
To be done in #69


else:
erika = Erika(com_port)
Expand Down Expand Up @@ -193,7 +191,7 @@ def main():
# with argcomplete used now, this shoudl be the very first call - no side-effects should happen before
argument_parser = create_argument_parser()
args = argument_parser.parse_args()
if ('func' in args):
if 'func' in args:
args.func(args)
else:
argument_parser.parse_args('-h')
Expand Down
Loading