from hamcrest import *
import unittest
from .hamcrest import evaluates_to

from blister.xmp import XMP

class XMPTest (unittest.TestCase):

    def test_degenerate (self):
        xmp = XMP()
        assert_that(xmp, evaluates_to(False))
        assert_that(xmp, has_length(0))
        assert_that(list(xmp), is_(equal_to([])))

    def test_not_all_attrs_exist (self):
        xmp = XMP()
        assert_that(calling(getattr).with_args(xmp, "fake_namespace"),
                    raises(AttributeError))
        assert_that(calling(getattr).with_args(xmp, "also_fake"),
                    raises(AttributeError))

    def test_default_xmp_namespaces_exist (self):
        xmp = XMP()
        no_error = xmp.stRef

from hamcrest import *
import unittest
from .hamcrest import evaluates_to

from blister.xmp import XMP

class XMPTest (unittest.TestCase):

    def setUp (self):
        self.xmp = XMP()

    def test_degenerate (self):
        assert_that(self.xmp, evaluates_to(False))
        assert_that(self.xmp, has_length(0))
        assert_that(list(self.xmp), is_(equal_to([])))

    def test_not_all_attrs_exist (self):
        assert_that(calling(getattr).with_args(self.xmp,
                                               "fake_namespace"),
                    raises(AttributeError))
        assert_that(calling(getattr).with_args(self.xmp, "also_fake"),
                    raises(AttributeError))

    def test_default_xmp_namespaces_exist (self):
        no_error = self.xmp.stRef

Move XMP init into setUp()
Move XMP init into setUp()

  from hamcrest import *
  import unittest
  from .hamcrest import evaluates_to
  
  from blister.xmp import XMP
  
  class XMPTest (unittest.TestCase):
  
+     def setUp (self):
+         self.xmp = XMP()
+ 
      def test_degenerate (self):
-         xmp = XMP()
-         assert_that(xmp, evaluates_to(False))
+         assert_that(self.xmp, evaluates_to(False))
-         assert_that(xmp, has_length(0))
+         assert_that(self.xmp, has_length(0))
-         assert_that(list(xmp), is_(equal_to([])))
+         assert_that(list(self.xmp), is_(equal_to([])))
  
      def test_not_all_attrs_exist (self):
-         xmp = XMP()
-         assert_that(calling(getattr).with_args(xmp, "fake_namespace"),
+         assert_that(calling(getattr).with_args(self.xmp,
+                                                "fake_namespace"),
                      raises(AttributeError))
-         assert_that(calling(getattr).with_args(xmp, "also_fake"),
+         assert_that(calling(getattr).with_args(self.xmp, "also_fake"),
                      raises(AttributeError))
  
      def test_default_xmp_namespaces_exist (self):
-         xmp = XMP()
-         no_error = xmp.stRef
+         no_error = self.xmp.stRef
  
Move XMP init into setUp()
## Code Before:
from hamcrest import *
import unittest
from .hamcrest import evaluates_to

from blister.xmp import XMP

class XMPTest (unittest.TestCase):

    def test_degenerate (self):
        xmp = XMP()
        assert_that(xmp, evaluates_to(False))
        assert_that(xmp, has_length(0))
        assert_that(list(xmp), is_(equal_to([])))

    def test_not_all_attrs_exist (self):
        xmp = XMP()
        assert_that(calling(getattr).with_args(xmp, "fake_namespace"),
                    raises(AttributeError))
        assert_that(calling(getattr).with_args(xmp, "also_fake"),
                    raises(AttributeError))

    def test_default_xmp_namespaces_exist (self):
        xmp = XMP()
        no_error = xmp.stRef

## Instruction:
Move XMP init into setUp()
## Code After:
from hamcrest import *
import unittest
from .hamcrest import evaluates_to

from blister.xmp import XMP

class XMPTest (unittest.TestCase):

    def setUp (self):
        self.xmp = XMP()

    def test_degenerate (self):
        assert_that(self.xmp, evaluates_to(False))
        assert_that(self.xmp, has_length(0))
        assert_that(list(self.xmp), is_(equal_to([])))

    def test_not_all_attrs_exist (self):
        assert_that(calling(getattr).with_args(self.xmp,
                                               "fake_namespace"),
                    raises(AttributeError))
        assert_that(calling(getattr).with_args(self.xmp, "also_fake"),
                    raises(AttributeError))

    def test_default_xmp_namespaces_exist (self):
        no_error = self.xmp.stRef
