<s> from django . db import DatabaseError <EOL> from django . utils import unittest <EOL> from regressiontests . max_lengths . models import PersonWithDefaultMaxLengths , PersonWithCustomMaxLengths <EOL> class MaxLengthArgumentsTests ( unittest . TestCase ) : <EOL> def verify_max_length ( self , model , field , length ) : <EOL> self . assertEqual ( model . _meta . get_field ( field ) . max_length , length ) <EOL> def test_default_max_lengths ( self ) : <EOL> self . verify_max_length ( PersonWithDefaultMaxLengths , '<STR_LIT:email>' , <NUM_LIT> ) <EOL> self . verify_max_length ( PersonWithDefaultMaxLengths , '<STR_LIT>' , <NUM_LIT:100> ) <EOL> self . verify_max_length ( PersonWithDefaultMaxLengths , '<STR_LIT>' , <NUM_LIT:200> ) <EOL> self . verify_max_length ( PersonWithDefaultMaxLengths , '<STR_LIT>' , <NUM_LIT:100> ) <EOL> def test_custom_max_lengths ( self ) : <EOL> self . verify_max_length ( PersonWithCustomMaxLengths , '<STR_LIT:email>' , <NUM_LIT> ) <EOL> self . verify_max_length ( PersonWithCustomMaxLengths , '<STR_LIT>' , <NUM_LIT> ) <EOL> self . verify_max_length ( PersonWithCustomMaxLengths , '<STR_LIT>' , <NUM_LIT> ) <EOL> self . verify_max_length ( PersonWithCustomMaxLengths , '<STR_LIT>' , <NUM_LIT> ) <EOL> class MaxLengthORMTests ( unittest . TestCase ) : <EOL> def test_custom_max_lengths ( self ) : <EOL> args = { <EOL> "<STR_LIT:email>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> for field in ( "<STR_LIT:email>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> new_args = args . copy ( ) <EOL> new_args [ field ] = "<STR_LIT:X>" * <NUM_LIT> <EOL> p = PersonWithCustomMaxLengths . objects . create ( ** new_args ) <EOL> self . assertEqual ( getattr ( p , field ) , ( "<STR_LIT:X>" * <NUM_LIT> ) ) </s>
