<s> from __future__ import unicode_literals <EOL> import unittest <EOL> import spotify <EOL> from spotify import utils <EOL> class ErrorTest ( unittest . TestCase ) : <EOL> def test_error_is_an_exception ( self ) : <EOL> error = spotify . Error ( <NUM_LIT:0> ) <EOL> self . assertIsInstance ( error , Exception ) <EOL> def test_maybe_raise ( self ) : <EOL> with self . assertRaises ( spotify . LibError ) : <EOL> spotify . Error . maybe_raise ( spotify . ErrorType . BAD_API_VERSION ) <EOL> def test_maybe_raise_does_not_raise_if_ok ( self ) : <EOL> spotify . Error . maybe_raise ( spotify . ErrorType . OK ) <EOL> def test_maybe_raise_does_not_raise_if_error_is_ignored ( self ) : <EOL> spotify . Error . maybe_raise ( <EOL> spotify . ErrorType . BAD_API_VERSION , <EOL> ignores = [ spotify . ErrorType . BAD_API_VERSION ] ) <EOL> def test_maybe_raise_works_with_any_iterable ( self ) : <EOL> spotify . Error . maybe_raise ( <EOL> spotify . ErrorType . BAD_API_VERSION , <EOL> ignores = ( spotify . ErrorType . BAD_API_VERSION , ) ) <EOL> class LibErrorTest ( unittest . TestCase ) : <EOL> def test_is_an_error ( self ) : <EOL> error = spotify . LibError ( <NUM_LIT:0> ) <EOL> self . assertIsInstance ( error , spotify . Error ) <EOL> def test_has_error_type ( self ) : <EOL> error = spotify . LibError ( <NUM_LIT:0> ) <EOL> self . assertEqual ( error . error_type , <NUM_LIT:0> ) <EOL> error = spotify . LibError ( <NUM_LIT:1> ) <EOL> self . assertEqual ( error . error_type , <NUM_LIT:1> ) <EOL> def test_is_equal_if_same_error_type ( self ) : <EOL> self . assertEqual ( spotify . LibError ( <NUM_LIT:0> ) , spotify . LibError ( <NUM_LIT:0> ) ) <EOL> def test_is_not_equal_if_different_error_type ( self ) : <EOL> self . assertNotEqual ( spotify . LibError ( <NUM_LIT:0> ) , spotify . LibError ( <NUM_LIT:1> ) ) <EOL> def test_error_has_useful_repr ( self ) : <EOL> error = spotify . LibError ( <NUM_LIT:0> ) <EOL> self . assertIn ( '<STR_LIT>' , repr ( error ) ) <EOL> def test_error_has_useful_string_representation ( self ) : <EOL> error = spotify . LibError ( <NUM_LIT:0> ) <EOL> self . assertEqual ( '<STR_LIT:%s>' % error , '<STR_LIT>' ) <EOL> self . assertIsInstance ( '<STR_LIT:%s>' % error , utils . text_type ) <EOL> error = spotify . LibError ( <NUM_LIT:1> ) <EOL> self . assertEqual ( '<STR_LIT:%s>' % error , '<STR_LIT>' ) <EOL> def test_has_error_constants ( self ) : <EOL> self . assertEqual ( <EOL> spotify . LibError . OK , spotify . LibError ( spotify . ErrorType . OK ) ) <EOL> self . assertEqual ( <EOL> spotify . LibError . BAD_API_VERSION , <EOL> spotify . LibError ( spotify . ErrorType . BAD_API_VERSION ) ) <EOL> class ErrorTypeTest ( unittest . TestCase ) : <EOL> def test_has_error_type_constants ( self ) : <EOL> self . assertEqual ( spotify . ErrorType . OK , <NUM_LIT:0> ) <EOL> self . assertEqual ( spotify . ErrorType . BAD_API_VERSION , <NUM_LIT:1> ) <EOL> class TimeoutTest ( unittest . TestCase ) : <EOL> def test_is_an_error ( self ) : <EOL> error = spotify . Timeout ( <NUM_LIT:0.5> ) <EOL> self . assertIsInstance ( error , spotify . Error ) <EOL> def test_has_useful_repr ( self ) : <EOL> error = spotify . Timeout ( <NUM_LIT:0.5> ) <EOL> self . assertIn ( '<STR_LIT>' , repr ( error ) ) <EOL> def test_has_useful_string_representation ( self ) : <EOL> error = spotify . Timeout ( <NUM_LIT:0.5> ) <EOL> self . assertEqual ( '<STR_LIT:%s>' % error , '<STR_LIT>' ) <EOL> self . assertIsInstance ( '<STR_LIT:%s>' % error , utils . text_type ) </s>
