Skip to content

Commit

Permalink
Try chardet for character encoding detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jayqi committed Mar 6, 2020
1 parent bb0a3ab commit 652d6e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-r requirements.txt

chardet
mkdocs
mkdocs-cinder
pipenv
Expand Down
9 changes: 6 additions & 3 deletions tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from subprocess import run, PIPE

import pytest
import chardet

from conftest import bake_project, config_generator

Expand Down Expand Up @@ -34,7 +35,7 @@ def test_baking_configs(config):
verify_folders(project_directory, config)
verify_files(project_directory, config)
verify_makefile_commands(project_directory, config)


def verify_folders(root, config):
''' Tests that expected folders and only expected folders exist.
Expand Down Expand Up @@ -148,9 +149,11 @@ def verify_makefile_commands(root, config):

result = run(["bash", str(harness_path), str(root.resolve())], stderr=PIPE, stdout=PIPE)

encoding = chardet.detect(result.stdout)["encoding"]

# normally hidden by pytest except in failure we want this displayed
print("\n======================= STDOUT ======================")
print(result.stdout.decode())
print(result.stdout.decode(encoding=encoding))
print("\n======================= STDERR ======================")
print(result.stderr.decode())
print(result.stderr.decode(encoding=encoding))
assert result.returncode == 0
11 changes: 10 additions & 1 deletion tests/virtualenv_harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,17 @@ export WORKON_HOME=$TEMP_ENV_ROOT
if [[ $(which virtualenvwrapper.sh) ]]; then
VIRTUALENVWRAPPER_SCRIPT=$(which virtualenvwrapper.sh)
else
VIRTUALENVWRAPPER_SCRIPT=$(find ${PATH//:/ } -name "virtualenvwrapper.sh" -maxdepth 1)
for path in ${PATH//:/ }; do
if [ -d "$path" ]; then
echo "Searching $path for virtualenvwrapper.sh"
FIND_RESULT=$(find $path -maxdepth 1 -name "virtualenvwrapper.sh")
if [[ "$FIND_RESULT" ]]; then
VIRTUALENVWRAPPER_SCRIPT=$FIND_RESULT
fi
fi
done
fi
echo VIRTUALENVWRAPPER_SCRIPT=$VIRTUALENVWRAPPER_SCRIPT
source $VIRTUALENVWRAPPER_SCRIPT

make create_environment
Expand Down

0 comments on commit 652d6e5

Please sign in to comment.