<s> from __future__ import absolute_import <EOL> import abc <EOL> import os <EOL> import shutil <EOL> import tempfile <EOL> import unittest <EOL> from six import with_metaclass <EOL> from gutenberg . _util . abc import abstractclassmethod <EOL> from gutenberg . _util . objects import all_subclasses <EOL> from gutenberg . _util . os import makedirs <EOL> from gutenberg . _util . os import remove <EOL> class TestAllSubclasses ( unittest . TestCase ) : <EOL> def test_all_subclasses ( self ) : <EOL> class Root ( object ) : <EOL> pass <EOL> class AB ( Root ) : <EOL> pass <EOL> class ABC ( AB ) : <EOL> pass <EOL> class AD ( Root ) : <EOL> pass <EOL> class ABAD ( AB , AD ) : <EOL> pass <EOL> class ABADE ( ABAD ) : <EOL> pass <EOL> self . assertTrue ( all_subclasses ( Root ) , set ( [ AB , ABC , AD , ABAD , ABADE ] ) ) <EOL> self . assertTrue ( all_subclasses ( ABADE ) == set ( ) ) <EOL> class TestAbstractClassMethod ( unittest . TestCase ) : <EOL> def test_abstractclassmethod ( self ) : <EOL> class ClassWithAbstractClassMethod ( with_metaclass ( abc . ABCMeta , object ) ) : <EOL> @ abstractclassmethod <EOL> def method ( cls ) : <EOL> pass <EOL> class ConcreteImplementation ( ClassWithAbstractClassMethod ) : <EOL> @ classmethod <EOL> def method ( cls ) : <EOL> pass <EOL> self . assertRaises ( TypeError , ClassWithAbstractClassMethod ) <EOL> ConcreteImplementation ( ) <EOL> class TestRemove ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . temporary_directory = tempfile . mkdtemp ( ) <EOL> self . temporary_file = tempfile . NamedTemporaryFile ( delete = False ) . name <EOL> def test_remove ( self ) : <EOL> for path in ( self . temporary_file , self . temporary_directory ) : <EOL> self . assertTrue ( os . path . exists ( path ) ) <EOL> remove ( path ) <EOL> self . assertFalse ( os . path . exists ( path ) ) <EOL> class TestMakedirs ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . temporary_directory = tempfile . mkdtemp ( ) <EOL> def tearDown ( self ) : <EOL> shutil . rmtree ( self . temporary_directory ) <EOL> def test_makedirs ( self ) : <EOL> path = os . path . join ( self . temporary_directory , '<STR_LIT:foo>' , '<STR_LIT:bar>' , '<STR_LIT>' ) <EOL> self . assertFalse ( os . path . exists ( path ) ) <EOL> makedirs ( path ) <EOL> self . assertTrue ( os . path . exists ( path ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
