#!/usr/bin/env python3

from passwd_change import passwd_change, shadow_change, mails_delete

from unittest import TestCase, TestLoader, TextTestRunner
import os
import subprocess


class PasswdChange_Test(TestCase):
    def setUp(self):
        """
        Preconditions
        """
        subprocess.call(['mkdir', 'test'])
        subprocess.call(['touch', 'test/rvv', 'test/max',
                         'test/mail'])
        #TODO create passwd test file
        #TODO create shadow test file
        #TODO create keys.txt file

    def tearDown(self):
        if os.path.exists('test/rvv'):
            raise Exception('test/rvv must not exist')
        if not (os.path.exists('test/max') and
                os.path.exists('test/bdv') and
                os.path.exists('test/mail')):
            raise Exception('File max, bdv or mail must exist!')
        subprocess.call(['rm', '-r', 'test/'])

    def test_passwd_change(self):
        shadow_change(*passwd_change())
        mails_delete(maildir_path='test')

    def test_passwd_change_2(self):
        shadow_change(*passwd_change())
        mails_delete(maildir_path='test/')


suite = TestLoader().loadTestsFromTestCase(PasswdChange_Test)
TextTestRunner(verbosity=2).run(suite)

@@ -403,16 +403,28 @@
         
+'test/bdv' ,
 'test/ma
@@ -425,24 +425,24 @@
 est/mail'%5D)%0A
-
         #TOD
@@ -557,32 +557,49 @@
 tearDown(self):%0A
+        try:%0A    
         if os.pa
@@ -625,32 +625,36 @@
 '):%0A            
+  
+  
 raise Exception(
@@ -688,16 +688,20 @@
         
+    
 if not (
@@ -727,24 +727,28 @@
 t/max') and%0A
+    
             
@@ -790,32 +790,36 @@
                 
+    
 os.path.exists('
@@ -832,16 +832,20 @@
 ail')):%0A
+    
         
@@ -901,16 +901,36 @@
 xist!')%0A
+        except:%0A    
         
@@ -967,16 +967,34 @@
 test/'%5D)
+%0A            raise
 %0A%0A    de

Add MIT LICENSE. Fix test dir removing issue - re-raise exception after delete this dir.