mirror of
				https://github.com/cookiecutter/cookiecutter-django.git
				synced 2025-11-04 09:57:30 +03:00 
			
		
		
		
	* Fix inconsistent line length and move config to pyproject.toml Fix #2720 * Fix running tox with AUTOFIXABLE_STYLES * Adjust some styles * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Adjust more styles * Split isort and flake8 tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
		
			
				
	
	
		
			27 lines
		
	
	
		
			709 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			709 B
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Unit tests for the hooks"""
 | 
						|
import os
 | 
						|
from pathlib import Path
 | 
						|
 | 
						|
import pytest
 | 
						|
 | 
						|
from hooks.post_gen_project import append_to_gitignore_file
 | 
						|
 | 
						|
 | 
						|
@pytest.fixture()
 | 
						|
def working_directory(tmp_path):
 | 
						|
    prev_cwd = Path.cwd()
 | 
						|
    os.chdir(tmp_path)
 | 
						|
    try:
 | 
						|
        yield tmp_path
 | 
						|
    finally:
 | 
						|
        os.chdir(prev_cwd)
 | 
						|
 | 
						|
 | 
						|
def test_append_to_gitignore_file(working_directory):
 | 
						|
    gitignore_file = working_directory / ".gitignore"
 | 
						|
    gitignore_file.write_text("node_modules/\n")
 | 
						|
    append_to_gitignore_file(".envs/*")
 | 
						|
    linesep = os.linesep.encode()
 | 
						|
    assert gitignore_file.read_bytes() == b"node_modules/" + linesep + b".envs/*" + linesep
 | 
						|
    assert gitignore_file.read_text() == "node_modules/\n.envs/*\n"
 |