Skip to content

Commit c89d312

Browse files
committed
[docs] Add documentation for module tests.test_archs
1 parent 614d584 commit c89d312

File tree

1 file changed

+81
-9
lines changed

1 file changed

+81
-9
lines changed

tests/test_archs.py

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646

4747

4848
class ArchSetUpBaseClass(object):
49+
"""
50+
An class object which is intended to be used as a base class to configure
51+
an inherited class of `unittest.TestCase`. This class will override the
52+
`setUp` method.
53+
"""
4954
ctx = None
5055

5156
def setUp(self):
@@ -63,6 +68,11 @@ def setUp(self):
6368

6469

6570
class TestArch(ArchSetUpBaseClass, unittest.TestCase):
71+
"""
72+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
73+
will be used to perform tests for the base class
74+
:class:`~pythonforandroid.archs.Arch`.
75+
"""
6676
def test_arch(self):
6777
arch = Arch(self.ctx)
6878
with self.assertRaises(AttributeError) as e1:
@@ -81,14 +91,27 @@ def test_arch(self):
8191

8292

8393
class TestArchARM(ArchSetUpBaseClass, unittest.TestCase):
84-
# Here we mock two functions:
85-
# - `ensure_dir` because we don't want to create any directory
86-
# - `find_executable` because otherwise we will
87-
# get an error when trying to find the compiler (we are setting some fake
88-
# paths for our android sdk and ndk so probably will not exist)
94+
"""
95+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
96+
will be used to perform tests for :class:`~pythonforandroid.archs.ArchARM`.
97+
"""
8998
@mock.patch("pythonforandroid.archs.find_executable")
9099
@mock.patch("pythonforandroid.build.ensure_dir")
91100
def test_arch_arm(self, mock_ensure_dir, mock_find_executable):
101+
"""
102+
Test that class :class:`~pythonforandroid.archs.ArchARM` returns some
103+
expected attributes and environment variables.
104+
105+
.. note::
106+
Here we mock two methods:
107+
108+
- `ensure_dir` because we don't want to create any directory
109+
- `find_executable` because otherwise we will
110+
get an error when trying to find the compiler (we are setting
111+
some fake paths for our android sdk and ndk so probably will
112+
not exist)
113+
114+
"""
92115
mock_find_executable.return_value = "arm-linux-androideabi-gcc"
93116
mock_ensure_dir.return_value = True
94117

@@ -147,16 +170,30 @@ def test_arch_arm(self, mock_ensure_dir, mock_find_executable):
147170

148171

149172
class TestArchARMv7a(ArchSetUpBaseClass, unittest.TestCase):
150-
# Here we mock the same functions than the previous tests plus `glob`,
151-
# so we make sure that the glob result is the expected even if the folder
152-
# doesn't exist, which is probably the case. This has to be done because
153-
# here we tests the `get_env` with clang
173+
"""
174+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
175+
will be used to perform tests for
176+
:class:`~pythonforandroid.archs.ArchARMv7_a`.
177+
"""
178+
154179
@mock.patch("pythonforandroid.archs.glob")
155180
@mock.patch("pythonforandroid.archs.find_executable")
156181
@mock.patch("pythonforandroid.build.ensure_dir")
157182
def test_arch_armv7a(
158183
self, mock_ensure_dir, mock_find_executable, mock_glob
159184
):
185+
"""
186+
Test that class :class:`~pythonforandroid.archs.ArchARMv7_a` returns
187+
some expected attributes and environment variables.
188+
189+
.. note::
190+
Here we mock the same functions than
191+
:meth:`TestArchARM.test_arch_arm` plus `glob`, so we make sure that
192+
the glob result is the expected even if the folder doesn't exist,
193+
which is probably the case. This has to be done because here we
194+
tests the `get_env` with clang
195+
196+
"""
160197
mock_find_executable.return_value = "arm-linux-androideabi-gcc"
161198
mock_ensure_dir.return_value = True
162199
mock_glob.return_value = ["llvm"]
@@ -197,9 +234,20 @@ def test_arch_armv7a(
197234

198235

199236
class TestArchX86(ArchSetUpBaseClass, unittest.TestCase):
237+
"""
238+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
239+
will be used to perform tests for :class:`~pythonforandroid.archs.Archx86`.
240+
"""
200241
@mock.patch("pythonforandroid.archs.find_executable")
201242
@mock.patch("pythonforandroid.build.ensure_dir")
202243
def test_arch_x86(self, mock_ensure_dir, mock_find_executable):
244+
"""
245+
Test that class :class:`~pythonforandroid.archs.Archx86` returns
246+
some expected attributes and environment variables.
247+
248+
.. note:: Here we mock the same functions than
249+
:meth:`TestArchARM.test_arch_arm`
250+
"""
203251
mock_find_executable.return_value = "arm-linux-androideabi-gcc"
204252
mock_ensure_dir.return_value = True
205253

@@ -220,9 +268,21 @@ def test_arch_x86(self, mock_ensure_dir, mock_find_executable):
220268

221269

222270
class TestArchX86_64(ArchSetUpBaseClass, unittest.TestCase):
271+
"""
272+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
273+
will be used to perform tests for
274+
:class:`~pythonforandroid.archs.Archx86_64`.
275+
"""
223276
@mock.patch("pythonforandroid.archs.find_executable")
224277
@mock.patch("pythonforandroid.build.ensure_dir")
225278
def test_arch_x86_64(self, mock_ensure_dir, mock_find_executable):
279+
"""
280+
Test that class :class:`~pythonforandroid.archs.Archx86_64` returns
281+
some expected attributes and environment variables.
282+
283+
.. note:: Here we mock the same functions than
284+
:meth:`TestArchARM.test_arch_arm`
285+
"""
226286
mock_find_executable.return_value = "arm-linux-androideabi-gcc"
227287
mock_ensure_dir.return_value = True
228288

@@ -242,9 +302,21 @@ def test_arch_x86_64(self, mock_ensure_dir, mock_find_executable):
242302

243303

244304
class TestArchAArch64(ArchSetUpBaseClass, unittest.TestCase):
305+
"""
306+
An inherited class of `ArchSetUpBaseClass` and `unittest.TestCase` which
307+
will be used to perform tests for
308+
:class:`~pythonforandroid.archs.ArchAarch_64`.
309+
"""
245310
@mock.patch("pythonforandroid.archs.find_executable")
246311
@mock.patch("pythonforandroid.build.ensure_dir")
247312
def test_arch_aarch_64(self, mock_ensure_dir, mock_find_executable):
313+
"""
314+
Test that class :class:`~pythonforandroid.archs.ArchAarch_64` returns
315+
some expected attributes and environment variables.
316+
317+
.. note:: Here we mock the same functions than
318+
:meth:`TestArchARM.test_arch_arm`
319+
"""
248320
mock_find_executable.return_value = "arm-linux-androideabi-gcc"
249321
mock_ensure_dir.return_value = True
250322

0 commit comments

Comments
 (0)