<s> from __future__ import with_statement <EOL> import datetime <EOL> from vcs . tests . base import BackendTestMixin <EOL> from vcs . tests . conf import SCM_TESTS <EOL> from vcs . nodes import FileNode <EOL> from vcs . utils . compat import unittest <EOL> class GetitemTestCaseMixin ( BackendTestMixin ) : <EOL> @ classmethod <EOL> def _get_commits ( cls ) : <EOL> start_date = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:20> ) <EOL> for x in xrange ( <NUM_LIT:5> ) : <EOL> yield { <EOL> '<STR_LIT:message>' : '<STR_LIT>' % x , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:date>' : start_date + datetime . timedelta ( hours = <NUM_LIT:12> * x ) , <EOL> '<STR_LIT>' : [ <EOL> FileNode ( '<STR_LIT>' % x , content = '<STR_LIT>' % x ) , <EOL> ] , <EOL> } <EOL> def test__getitem__last_item_is_tip ( self ) : <EOL> self . assertEqual ( self . repo [ - <NUM_LIT:1> ] , self . repo . get_changeset ( ) ) <EOL> def test__getitem__returns_correct_items ( self ) : <EOL> changesets = [ self . repo [ x ] for x in xrange ( len ( self . repo . revisions ) ) ] <EOL> self . assertEqual ( changesets , list ( self . repo . get_changesets ( ) ) ) <EOL> for alias in SCM_TESTS : <EOL> attrs = { <EOL> '<STR_LIT>' : alias , <EOL> } <EOL> cls_name = '<STR_LIT>' . join ( ( '<STR_LIT>' % alias ) . title ( ) . split ( ) ) <EOL> bases = ( GetitemTestCaseMixin , unittest . TestCase ) <EOL> globals ( ) [ cls_name ] = type ( cls_name , bases , attrs ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
