shot-scraper
shot-scraper copied to clipboard
Add color scheme option to CLI and update example scripts
Hi @simonw - just a simple change here to add to option of taking native dark mode screenshots, as well as adding a couple example tests.
📚 Documentation preview 📚: https://shot-scraper--172.org.readthedocs.build/en/172/
Weird errors:
tests/test_shot_scraper.py ...................F.F.F............ [ 83%]
tests/test_utils.py ....... [100%]
=================================== FAILURES ===================================
_ test_error_on_invalid_scale_factors[shot-args0-Error: --retina and --scale-factor cannot be used together\n] _
command = 'shot', args = ['--retina', '--scale-factor', 3]
expected = 'Error: --retina and --scale-factor cannot be used together\n'
@pytest.mark.parametrize(
"command,args,expected",
[
(
"shot",
["--retina", "--scale-factor", 3],
"Error: --retina and --scale-factor cannot be used together\n",
),
(
"multi",
["--retina", "--scale-factor", 3],
"Error: --retina and --scale-factor cannot be used together\n",
),
(
"shot",
["--scale-factor", 0],
"Error: --scale-factor must be positive\n",
),
(
"multi",
["--scale-factor", 0],
"Error: --scale-factor must be positive\n",
),
(
"shot",
["--scale-factor", -3],
"Error: --scale-factor must be positive\n",
),
(
"multi",
["--scale-factor", -3],
"Error: --scale-factor must be positive\n",
),
],
)
def test_error_on_invalid_scale_factors(command, args, expected):
runner = CliRunner()
result = runner.invoke(cli, [command, "-"] + args)
assert result.exit_code == 1
> assert result.output == expected
E AssertionError: assert '' == 'Error: --sca...be positive\n'
E
E - Error: --scale-factor must be positive
tests/test_shot_scraper.py:216: AssertionError
_ test_error_on_invalid_scale_factors[shot-args4-Error: --scale-factor must be positive\n] _
command = 'shot', args = ['--scale-factor', -3]
expected = 'Error: --scale-factor must be positive\n'
@pytest.mark.parametrize(
"command,args,expected",
[
(
"shot",
["--retina", "--scale-factor", 3],
"Error: --retina and --scale-factor cannot be used together\n",
),
(
"multi",
["--retina", "--scale-factor", 3],
"Error: --retina and --scale-factor cannot be used together\n",
),
(
"shot",
["--scale-factor", 0],
"Error: --scale-factor must be positive\n",
),
(
"multi",
["--scale-factor", 0],
"Error: --scale-factor must be positive\n",
),
(
"shot",
["--scale-factor", -3],
"Error: --scale-factor must be positive\n",
),
(
"multi",
["--scale-factor", -3],
"Error: --scale-factor must be positive\n",
),
],
)
def test_error_on_invalid_scale_factors(command, args, expected):
runner = CliRunner()
result = runner.invoke(cli, [command, "-"] + args)
assert result.exit_code == 1
> assert result.output == expected
E AssertionError: assert '' == 'Error: --sca...be positive\n'
E
E - Error: --scale-factor must be positive
tests/test_shot_scraper.py:216: AssertionError
=========================== short test summary info ============================
FAILED tests/test_shot_scraper.py::test_error_on_invalid_scale_factors[shot-args0-Error: --retina and --scale-factor cannot be used together\n] - AssertionError: assert '' == 'Error: --ret...ed together\n'
- Error: --retina and --scale-factor cannot be used together
FAILED tests/test_shot_scraper.py::test_error_on_invalid_scale_factors[shot-args2-Error: --scale-factor must be positive\n] - AssertionError: assert '' == 'Error: --sca...be positive\n'
- Error: --scale-factor must be positive
FAILED tests/test_shot_scraper.py::test_error_on_invalid_scale_factors[shot-args4-Error: --scale-factor must be positive\n] - AssertionError: assert '' == 'Error: --sca...be positive\n'
- Error: --scale-factor must be positive
=================== 3 failed, 40 passed in 83.89s (0:01:23) ====================
My apologies @simonw - I should have run the pytest suite before submitting the PR. I just assumed it was minor enough that it would pass, but that's on me. I'll do some more testing and push a fix.
@simonw i think that one should do the trick! Passing all pytests for me now.