old_contents: from __future__ import unicode_literals
  
  from datetime import date
  
  from django.test import TestCase
  
  from import_export import fields
  
  
  class Obj:
  
      def __init__(self, name, date=None):
          self.name = name
          self.date = date
  
  
  class FieldTest(TestCase):
  
      def setUp(self):
          self.field = fields.Field(column_name='name', attribute='name')
          self.row = {
              'name': 'Foo',
              }
          self.obj = Obj(name='Foo', date=date(2012, 8, 13))
  
      def test_clean(self):
          self.assertEqual(self.field.clean(self.row),
                           self.row['name'])
  
      def test_export(self):
          self.assertEqual(self.field.export(self.obj),
                           self.row['name'])
  
      def test_save(self):
          self.row['name'] = 'foo'
          self.field.save(self.obj, self.row)
          self.assertEqual(self.obj.name, 'foo')
  
      def test_save_follow(self):
          class Test:
              class name:
                  class follow:
                      me = 'bar'
          test = Test()
          field = fields.Field(column_name='name', attribute='name__follow__me')
          row = {'name': 'foo'}
          field.save(test, row)
          self.assertEqual(test.name.follow.me, 'foo')
  
      def test_following_attribute(self):
          field = fields.Field(attribute='other_obj__name')
          obj2 = Obj(name="bar")
          self.obj.other_obj = obj2
          self.assertEqual(field.export(self.obj), "bar")
  
new_contents: from __future__ import unicode_literals
  
  from datetime import date
  
  from django.test import TestCase
  
  from import_export import fields
  
  
  class Obj:
  
      def __init__(self, name, date=None):
          self.name = name
          self.date = date
  
  
  class FieldTest(TestCase):
  
      def setUp(self):
          self.field = fields.Field(column_name='name', attribute='name')
          self.row = {
              'name': 'Foo',
              }
          self.obj = Obj(name='Foo', date=date(2012, 8, 13))
  
      def test_clean(self):
          self.assertEqual(self.field.clean(self.row),
                           self.row['name'])
  
      def test_export(self):
          self.assertEqual(self.field.export(self.obj),
                           self.row['name'])
  
      def test_save(self):
          self.row['name'] = 'foo'
          self.field.save(self.obj, self.row)
          self.assertEqual(self.obj.name, 'foo')
  
      def test_save_follow(self):
          class Test:
              class name:
                  class follow:
                      me = 'bar'
          test = Test()
          field = fields.Field(column_name='name', attribute='name__follow__me')
          row = {'name': 'foo'}
          field.save(test, row)
          self.assertEqual(test.name.follow.me, 'foo')
  
      def test_following_attribute(self):
          field = fields.Field(attribute='other_obj__name')
          obj2 = Obj(name="bar")
          self.obj.other_obj = obj2
          self.assertEqual(field.export(self.obj), "bar")
  
      def test_default(self):
          field = fields.Field(default=1, column_name='name')
          self.assertEqual(field.clean({'name': None}), 1)
  
subject: Add test for 4c65918