~mterry/duplicity/py3-map-filter

« back to all changes in this revision

Viewing changes to testing/unit/test_dup_temp.py

  • Committer: Kenneth Loafman
  • Date: 2014-04-20 15:32:17 UTC
  • mfrom: (977.1.8 test-reorg)
  • Revision ID: kenneth@loafman.com-20140420153217-n4jt28oo4q7d6bzu
# Merged in lp:~mterry/duplicity/more-test-reorg
  - Here's another test reorganization / modernization branch. It does the
    following things:
    - Drop duplicity/misc.py. It is confusing to have both misc.py and util.py,
      and most of the code in misc.py was no longer used. I moved the one
      function that was still used into util.py.
    - Consolidated the various ways to run tests into just one. I made tox runs
      go through ./setup.py test, rather than nosetests. And I made the
      ./testing/run-tests scripts just call tox. Now we no longer need nosetests
      as a test dependency (although you can still use it if you want).
    - Added two more code quality automated tests: a pep8 one and a pylint one.
      I disabled almost all checks in each program that gave a warning. These
      tests just establish a baseline for future improvement.
    - Moved the test helper code into TestCase subclasses that all tests can
      use. And used more code sharing and setUp/tearDown cleverness to remove
      duplicated code.
    - Reorganized the tests in ./testing/tests into ./testing/functional and
      ./testing/unit -- for whether they drive duplicity as a subprocess or
      whether they import and test code directly. Each dir can have specialized
      TestCase subclasses now.
    - Renamed the files in ./testing/unit to more clearly indicate which file
      in ./duplicity they are unit testing.
    - Added some helper methods for tests to set environment and globals.*
      parameters more safely (i.e. without affecting other tests) by
      automatically cleaning up any such changes during test tearDown.
    - Removed test_unicode.py, since it is kind of dumb. It used to be more
      useful, but now with py2.6, we are just testing that one line of code
      in it is actually there.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# along with duplicity; if not, write to the Free Software Foundation,
20
20
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
21
 
22
 
import helper
23
 
import sys, os, unittest, gzip
 
22
import gzip
 
23
import unittest
24
24
 
25
25
from duplicity import dup_temp
26
26
from duplicity import file_naming
27
 
 
28
 
helper.setup()
29
 
 
30
 
prefix = "testfiles/output"
31
 
 
32
 
class TempTest(unittest.TestCase):
 
27
from . import UnitTestCase
 
28
 
 
29
 
 
30
class TempTest(UnitTestCase):
33
31
    """Test various temp files methods"""
34
 
    def setUp(self):
35
 
        assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
36
 
 
37
 
    def tearDown(self):
38
 
        assert not os.system("rm -rf testfiles tempdir temp2.tar")
39
 
 
40
 
    def del_tmp(self):
41
 
        """Delete testfiles/output and recreate"""
42
 
        assert not os.system("rm -rf " + prefix)
43
 
        assert not os.system("mkdir " + prefix)
44
32
 
45
33
    def test_temppath(self):
46
34
        """Allocate new temppath, try open_with_delete"""