diff --git a/tests/test_import_export.py b/tests/test_import_export.py index f7418d50..0ba305bf 100644 --- a/tests/test_import_export.py +++ b/tests/test_import_export.py @@ -9,6 +9,7 @@ import pytest from django.contrib.auth.models import Group from django.core.files import File from django.core.management import call_command +from django.utils.encoding import force_bytes from django.utils.six import BytesIO, StringIO from combo.apps.assets.models import Asset @@ -37,12 +38,12 @@ def some_map_layers(): @pytest.fixture def some_assets(): - Asset(key='banner', asset=File(StringIO('test'), 'test.png')).save() - Asset(key='favicon', asset=File(StringIO('test2'), 'test2.png')).save() + Asset(key='banner', asset=File(BytesIO(b'test'), 'test.png')).save() + Asset(key='favicon', asset=File(BytesIO(b'test2'), 'test2.png')).save() def get_output_of_command(command, *args, **kwargs): old_stdout = sys.stdout - output = sys.stdout = BytesIO() + output = sys.stdout = StringIO() call_command(command, *args, **kwargs) sys.stdout = old_stdout return output.getvalue() @@ -67,7 +68,7 @@ def test_import_export(app, some_data): assert Page.objects.count() == 0 with tempfile.NamedTemporaryFile() as f: - f.write(output) + f.write(force_bytes(output)) f.flush() call_command('import_site', f.name) @@ -109,7 +110,7 @@ def test_import_export_map_layers(app, some_map_layers): assert MapLayer.objects.count() == 0 with tempfile.NamedTemporaryFile() as f: - f.write(output) + f.write(force_bytes(output)) f.flush() call_command('import_site', f.name) @@ -189,7 +190,7 @@ def test_import_export_assets(app, some_assets): assert Asset.objects.count() == 0 with tempfile.NamedTemporaryFile() as f: - f.write(output) + f.write(force_bytes(output)) f.flush() call_command('import_site', f.name)