Skip to content

Commit eca86d2

Browse files
committed
✅ Fix broken sdl2 mixer test
Reproduce with: ``` PYTHONPATH=. pytest tests/recipes/test_sdl2_mixer.py ``` The error was: ``` =================================== FAILURES =================================== __________________ TestSDL2MixerRecipe.test_get_include_dirs ___________________ self = <test_sdl2_mixer.TestSDL2MixerRecipe testMethod=test_get_include_dirs> def test_get_include_dirs(self): > list_of_includes = self.recipe.get_include_dirs(self.arch) tests/recipes/test_sdl2_mixer.py:12: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pythonforandroid/recipes/sdl2_mixer/__init__.py:13: in get_include_dirs os.path.join(self.ctx.bootstrap.build_dir, "jni", "SDL2_mixer", "include") _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = None, p = ('jni', 'SDL2_mixer', 'include') > ??? E TypeError: expected str, bytes or os.PathLike object, not NoneType <frozen posixpath>:76: TypeError ``` Also do some minor code clean up and absolute import path fixes.
1 parent 9ef3f9f commit eca86d2

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

tests/recipes/test_sdl2_mixer.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import unittest
2-
from tests.recipes.recipe_lib_test import RecipeCtx
2+
from tests.recipes.recipe_ctx import RecipeCtx
33

44

55
class TestSDL2MixerRecipe(RecipeCtx, unittest.TestCase):
@@ -8,6 +8,12 @@ class TestSDL2MixerRecipe(RecipeCtx, unittest.TestCase):
88
"""
99
recipe_name = "sdl2_mixer"
1010

11+
def setUp(self):
12+
"""Setups bootstrap build_dir."""
13+
super().setUp()
14+
bootstrap = self.ctx.bootstrap
15+
bootstrap.build_dir = bootstrap.get_build_dir()
16+
1117
def test_get_include_dirs(self):
1218
list_of_includes = self.recipe.get_include_dirs(self.arch)
1319
self.assertIsInstance(list_of_includes, list)

tests/test_bootstrap.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from pythonforandroid.util import BuildInterruptingException
1616
from pythonforandroid.androidndk import AndroidNDK
1717

18-
from test_graph import get_fake_recipe
18+
from tests.test_graph import get_fake_recipe
1919

2020

21-
class BaseClassSetupBootstrap(object):
21+
class BaseClassSetupBootstrap:
2222
"""
23-
An class object which is intended to be used as a base class to configure
23+
An class which is intended to be used as a base class to configure
2424
an inherited class of `unittest.TestCase`. This class will override the
2525
`setUp` and `tearDown` methods.
2626
"""
@@ -115,7 +115,7 @@ def test__cmp_bootstraps_by_priority(self):
115115
) < 0)
116116

117117
# Test a random bootstrap is always lower priority than sdl2:
118-
class _FakeBootstrap(object):
118+
class _FakeBootstrap:
119119
def __init__(self, name):
120120
self.name = name
121121
bs1 = _FakeBootstrap("alpha")

tests/test_recipe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import os
22
import pytest
3+
import tempfile
34
import types
45
import unittest
56
import warnings
67
from unittest import mock
7-
from backports import tempfile
88

99
from pythonforandroid.build import Context
1010
from pythonforandroid.recipe import Recipe, TargetPythonRecipe, import_recipe
1111
from pythonforandroid.archs import ArchAarch_64
1212
from pythonforandroid.bootstrap import Bootstrap
13-
from test_bootstrap import BaseClassSetupBootstrap
13+
from tests.test_bootstrap import BaseClassSetupBootstrap
1414

1515

1616
def patch_logger(level):

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ basepython = python3
66
deps =
77
pytest
88
py3: coveralls
9-
backports.tempfile
109
# posargs will be replaced by the tox args, so you can override pytest
1110
# args e.g. `tox -- tests/test_graph.py`
1211
commands = pytest {posargs:tests/}

0 commit comments

Comments
 (0)