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

Add color scheme option to CLI and update example scripts #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kcrommett
Copy link

@kcrommett kcrommett commented Mar 21, 2025

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/

@simonw simonw added the enhancement New feature or request label Mar 25, 2025
@simonw
Copy link
Owner

simonw commented Mar 25, 2025

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) ====================

@kcrommett
Copy link
Author

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.

@kcrommett
Copy link
Author

@simonw i think that one should do the trick! Passing all pytests for me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants