<s> from __future__ import absolute_import <EOL> from django . core . exceptions import FieldError <EOL> from django . test import TestCase <EOL> from . models import Author , Article <EOL> def pks ( objects ) : <EOL> """<STR_LIT>""" <EOL> return [ o . pk for o in objects ] <EOL> class CustomColumnRegression ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . a1 = Author . objects . create ( first_name = '<STR_LIT>' , last_name = '<STR_LIT>' ) <EOL> self . a2 = Author . objects . create ( first_name = '<STR_LIT>' , last_name = '<STR_LIT>' ) <EOL> self . authors = [ self . a1 , self . a2 ] <EOL> def test_basic_creation ( self ) : <EOL> art = Article ( headline = '<STR_LIT>' , primary_author = self . a1 ) <EOL> art . save ( ) <EOL> art . authors = [ self . a1 , self . a2 ] <EOL> def test_author_querying ( self ) : <EOL> self . assertQuerysetEqual ( <EOL> Author . objects . all ( ) . order_by ( '<STR_LIT>' ) , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> def test_author_filtering ( self ) : <EOL> self . assertQuerysetEqual ( <EOL> Author . objects . filter ( first_name__exact = '<STR_LIT>' ) , <EOL> [ '<STR_LIT>' ] <EOL> ) <EOL> def test_author_get ( self ) : <EOL> self . assertEqual ( self . a1 , Author . objects . get ( first_name__exact = '<STR_LIT>' ) ) <EOL> def test_filter_on_nonexistant_field ( self ) : <EOL> self . assertRaisesMessage ( <EOL> FieldError , <EOL> "<STR_LIT>" , <EOL> Author . objects . filter , <EOL> firstname__exact = '<STR_LIT>' <EOL> ) <EOL> def test_author_get_attributes ( self ) : <EOL> a = Author . objects . get ( last_name__exact = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , a . first_name ) <EOL> self . assertEqual ( '<STR_LIT>' , a . last_name ) <EOL> self . assertRaisesMessage ( <EOL> AttributeError , <EOL> "<STR_LIT>" , <EOL> getattr , <EOL> a , '<STR_LIT>' <EOL> ) <EOL> self . assertRaisesMessage ( <EOL> AttributeError , <EOL> "<STR_LIT>" , <EOL> getattr , <EOL> a , '<STR_LIT>' <EOL> ) <EOL> def test_m2m_table ( self ) : <EOL> art = Article . objects . create ( headline = '<STR_LIT>' , primary_author = self . a1 ) <EOL> art . authors = self . authors <EOL> self . assertQuerysetEqual ( <EOL> art . authors . all ( ) . order_by ( '<STR_LIT>' ) , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> self . a1 . article_set . all ( ) , <EOL> [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> art . authors . filter ( last_name = '<STR_LIT>' ) , <EOL> [ '<STR_LIT>' ] <EOL> ) </s>
