from alphatwirl.roottree import Branch
import unittest
import array

##__________________________________________________________________||
class TestBranch(unittest.TestCase):

    def test_repr(self):
        ar = array.array('d', [ 112.4, 87.6, 30.2])
        ca = array.array('i', [ 2 ])
        obj = Branch('jet_pt', ar, ca)
        repr(obj)

    def test_array(self):

        ar = array.array('d', [ 112.4, 87.6, 30.2])
        ca = array.array('i', [ 2 ])
        obj = Branch('jet_pt', ar, ca)

        self.assertEqual(2, len(obj))
        self.assertEqual(112.4, obj[0])
        self.assertEqual(87.6, obj[1])
        self.assertRaises(IndexError, obj.__getitem__, 2)

    def test_value(self):

        ar = array.array('d', [ 112.4])
        ca = None
        obj = Branch('met_pt', ar, ca)

        self.assertEqual(1, len(obj))
        self.assertEqual(112.4, obj[0])
        self.assertRaises(IndexError, obj.__getitem__, 1)

##__________________________________________________________________||

@@ -1,50 +1,61 @@
-from alphatwirl.roottree 
+# Tai Sakuma %3Ctai.sakuma@gmail.com%3E%0A
 import 
-Branch
+array%0A
 %0Aimport 
 unit
@@ -54,29 +54,54 @@
 ort 
-unit
+py
 test%0A
+%0Afrom alphatwirl.roottree 
 import 
-array
+Branch
 %0A%0A##
@@ -173,50 +173,8 @@
 _%7C%7C%0A
-class TestBranch(unittest.TestCase):%0A%0A    
 def 
@@ -187,19 +187,11 @@
 epr(
-self):%0A    
+):%0A
     
@@ -205,33 +205,32 @@
 ray.array('d', %5B
- 
 112.4, 87.6, 30.
@@ -225,36 +225,32 @@
 4, 87.6, 30.2%5D)%0A
-    
     ca = array.a
@@ -256,34 +256,28 @@
 array('i', %5B
- 2 %5D)%0A    
+2%5D)%0A
     obj = Br
@@ -303,19 +303,21 @@
 ca)%0A    
- 
-  
+print
  repr(ob
@@ -320,20 +320,16 @@
 r(obj)%0A%0A
-    
 def test
@@ -335,28 +335,19 @@
 t_array(
-self):%0A%0A    
+):%0A
     ar =
@@ -361,25 +361,24 @@
 array('d', %5B
- 
 112.4, 87.6,
@@ -385,20 +385,16 @@
  30.2%5D)%0A
-    
     ca =
@@ -416,18 +416,12 @@
 ', %5B
- 2 %5D)%0A    
+2%5D)%0A
     
@@ -460,31 +460,19 @@
     
-    self.assertEqual(2,
+assert 2 ==
  len
@@ -480,152 +480,114 @@
 obj)
-)
 %0A    
-    self.assertEqual(
+assert 
 112.4
-,
+ ==
  obj%5B0%5D
-)
 %0A    
-    self.assertEqual(
+assert 
 87.6
-,
+ ==
  obj%5B1%5D
-)
 %0A    
-    self.assertRaises(IndexError, obj.__getitem__, 2)%0A%0A    
+with pytest.raises(IndexError):%0A        obj%5B2%5D%0A%0A
 def 
@@ -601,24 +601,15 @@
 lue(
-self):%0A%0A  
+):%0A
     
-  
 ar =
@@ -631,17 +631,16 @@
 ', %5B
- 
 112.4%5D)%0A
     
@@ -635,20 +635,16 @@
 112.4%5D)%0A
-    
     ca =
@@ -649,20 +649,16 @@
  = None%0A
-    
     obj 
@@ -693,31 +693,19 @@
     
-  
-  self.assertEqual(1,
+assert 1 ==
  len
@@ -713,107 +713,86 @@
 obj)
-)%0A 
+%0A
     
-   self.assertEqual(
+assert 
 112.4
-,
+ ==
  obj%5B0%5D
-)
 %0A    
-    self.assertRaises(IndexError, obj.__getitem__, 1)
+with pytest.raises(IndexError):%0A        obj%5B1%5D
 %0A%0A##

rewrite test for Branch with pytest