Source code for sknano.testing._tools
# -*- coding: utf-8 -*-
"""
========================================================================
Test fixtures (:mod:`sknano.testing._tools`)
========================================================================
.. currentmodule:: sknano.testing._tools
"""
from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals
from ._funcs import generate_atoms
__all__ = ['GeneratorTestFixtures', 'AtomsTestFixture']
import os
import unittest
[docs]class GeneratorTestFixtures(unittest.TestCase):
"""Mixin unittest.TestCase class defining setUp/tearDown methods to
keep track of and delete the structure data files generated by the
sknano.generators classes."""
[docs] def setUp(self):
self.tmpdata = []
[docs] def tearDown(self):
for f in self.tmpdata:
try:
os.remove(f)
except IOError:
continue
[docs]class AtomsTestFixture(unittest.TestCase):
"""Mixin unittest.TestCase class defining setUp method to generate list
of atoms."""
[docs] def setUp(self):
self.atoms = \
generate_atoms(generator_class='SWNTGenerator', n=10, m=0, nz=5)
self.atoms.assign_unique_ids()