Skip to content

Commit

Permalink
Fix unclosed file warning and make tests discover warnings (#179)
Browse files Browse the repository at this point in the history
* Fix "ResourceWarning: unclosed file" in compilescss

* Enforce warnings not pass tests
  • Loading branch information
washeck committed Mar 27, 2024
1 parent a4bf114 commit 17f9fb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[pytest]
DJANGO_SETTINGS_MODULE = tests.settings
addopts = --tb native
filterwarnings = error
3 changes: 2 additions & 1 deletion sass_processor/management/commands/compilescss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from importlib import import_module
import sass
from compressor.exceptions import TemplateDoesNotExist, TemplateSyntaxError
from pathlib import Path

from django.apps import apps
from django.conf import settings
Expand Down Expand Up @@ -200,7 +201,7 @@ def parse_source(self, filename):
`sass_processor(scss_file)` and compile the filename into CSS.
"""
callvisitor = FuncCallVisitor('sass_processor')
tree = ast.parse(open(filename, 'rb').read())
tree = ast.parse(Path(filename).read_bytes())
callvisitor.visit(tree)
for sass_fileurl in callvisitor.sass_files:
sass_filename = find_file(sass_fileurl)
Expand Down

0 comments on commit 17f9fb5

Please sign in to comment.