Skip to content

Conversation

@h4iku
Copy link

@h4iku h4iku commented Nov 22, 2025

The file tests/test-generate-context/non_ascii.json needs to exist in the buggy version for the test to run correctly because the test passes it as input to the function under test: cookiecutter/cookiecutter@7f6804c
Without it, a FileNotFoundError occurs:

=================================== FAILURES ===================================
________________ test_generate_context_decodes_non_ascii_chars _________________

    def test_generate_context_decodes_non_ascii_chars():
        """Verify `generate_context` correctly decodes non-ascii chars."""
        expected_context = {'non_ascii': OrderedDict([('full_name', 'éèà'),])}
    
        generated_context = generate.generate_context(
>           context_file='tests/test-generate-context/non_ascii.json'
        )

tests/test_generate_context.py:116: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

context_file = 'tests/test-generate-context/non_ascii.json'
default_context = None, extra_context = None

    def generate_context(
        context_file='cookiecutter.json', default_context=None, extra_context=None
    ):
        """Generate the context for a Cookiecutter project template.
    
        Loads the JSON file as a Python object, with key being the JSON filename.
    
        :param context_file: JSON file containing key/value pairs for populating
            the cookiecutter's variables.
        :param default_context: Dictionary containing config to take into account.
        :param extra_context: Dictionary containing configuration overrides
        """
        context = OrderedDict([])
    
        try:
>           with open(context_file) as file_handle:
E           FileNotFoundError: [Errno 2] No such file or directory: 'tests/test-generate-context/non_ascii.json'

cookiecutter/generate.py:85: FileNotFoundError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant