old_contents: # -*- coding: utf-8 -*-
  
  # Copyright (c) 2018 shmilee
  
  import os
  import unittest
  import tempfile
  
  from ..base import BaseFileSaver
  
  
  class TestBaseFileSaver(unittest.TestCase):
      '''
      Test class BaseFileSaver
      '''
  
      def setUp(self):
          self.tmp = tempfile.mktemp(suffix='-test')
          self.tmpfile = self.tmp + BaseFileSaver._extension
  
      def tearDown(self):
          if os.path.isfile(self.tmpfile):
              os.remove(self.tmpfile)
  
      def test_filesaver_init(self):
          saver = BaseFileSaver(self.tmp)
          self.assertTrue(saver.file == self.tmpfile)
          self.assertIsNone(saver.fobj)
          with self.assertRaises(IOError):
              BaseFileSaver(os.path.join(self.tmpfile, 'BreakSuffix'))
  
      def test_filesaver_iopen(self):
          saver = BaseFileSaver(self.tmpfile)
          with self.assertRaises(NotImplementedError):
              saver.iopen()
  
      def test_filesaver_write(self):
          saver = BaseFileSaver(self.tmpfile)
          with open(saver.file, mode='w') as saver.fobj:
              with self.assertRaises(NotImplementedError):
                  saver.write('g', {'t': 1})
  
      def test_filesaver_close(self):
          saver = BaseFileSaver(self.tmpfile)
          with open(saver.file, mode='w') as saver.fobj:
              with self.assertRaises(NotImplementedError):
                  saver.close()
  
new_contents: # -*- coding: utf-8 -*-
  
  # Copyright (c) 2018 shmilee
  
  import os
  import unittest
  import tempfile
  
  from ..base import BasePckSaver
  
  
  class TestBasePckSaver(unittest.TestCase):
      '''
      Test class BasePckSaver
      '''
  
      def setUp(self):
          self.tmp = tempfile.mktemp(suffix='-test')
          self.tmpfile = self.tmp + BasePckSaver._extension
  
      def tearDown(self):
          if os.path.isfile(self.tmpfile):
              os.remove(self.tmpfile)
  
      def test_pcksaver_init(self):
          saver = BasePckSaver(self.tmp)
          self.assertTrue(saver.path == self.tmpfile)
          self.assertIsNone(saver._storeobj)
          with self.assertRaises(IOError):
              BasePckSaver(os.path.join(self.tmpfile, 'BreakSuffix'))
  
      def test_pcksaver_iopen(self):
          saver = BasePckSaver(self.tmpfile)
          with self.assertRaises(NotImplementedError):
              saver.iopen()
  
      def test_pcksaver_write(self):
          saver = BasePckSaver(self.tmpfile)
          with open(saver.path, mode='w') as saver._storeobj:
              saver.status = True
              with self.assertRaises(NotImplementedError):
                  saver.write('g', {'t': 1})
  
      def test_pcksaver_close(self):
          saver = BasePckSaver(self.tmpfile)
          with open(saver.path, mode='w') as saver._storeobj:
              saver.status = True
              saver.close()
              self.assertIsNone(saver._storeobj)
  
      def test_pcksaver_get_store(self):
          saver = BasePckSaver(self.tmpfile)
          self.assertEqual(self.tmpfile, saver.get_store())
  
subject: add unittest for BasePckSaver