

import os
import unittest
from openquake.commonlib import nrml


def number_of(elem_name, tree):
    """
    Given an element name (including the namespaces prefix, if applicable),
    return the number of occurrences of the element in a given XML document.
    """
    expr = '//%s' % elem_name
    return len(tree.xpath(expr, namespaces=nrml.PARSE_NS_MAP))


class BaseExportTestCase(unittest.TestCase):
    def _test_exported_file(self, filename):
        self.assertTrue(os.path.exists(filename))
        self.assertTrue(os.path.isabs(filename))
        self.assertTrue(os.path.getsize(filename) > 0)



import os
import unittest
from openquake.commonlib import nrml


def number_of(elem_name, tree):
    """
    Given an element name (including the namespaces prefix, if applicable),
    return the number of occurrences of the element in a given XML document.
    """
    expr = '//%s' % elem_name
    return len(tree.xpath(expr, namespaces={'nrml': nrml.NRML05}))


class BaseExportTestCase(unittest.TestCase):
    def _test_exported_file(self, filename):
        self.assertTrue(os.path.exists(filename))
        self.assertTrue(os.path.isabs(filename))
        self.assertTrue(os.path.getsize(filename) > 0)

Fix a broken export test
Fix a broken export test

  
  
  import os
  import unittest
  from openquake.commonlib import nrml
  
  
  def number_of(elem_name, tree):
      """
      Given an element name (including the namespaces prefix, if applicable),
      return the number of occurrences of the element in a given XML document.
      """
      expr = '//%s' % elem_name
-     return len(tree.xpath(expr, namespaces=nrml.PARSE_NS_MAP))
+     return len(tree.xpath(expr, namespaces={'nrml': nrml.NRML05}))
  
  
  class BaseExportTestCase(unittest.TestCase):
      def _test_exported_file(self, filename):
          self.assertTrue(os.path.exists(filename))
          self.assertTrue(os.path.isabs(filename))
          self.assertTrue(os.path.getsize(filename) > 0)
  
Fix a broken export test
## Code Before:


import os
import unittest
from openquake.commonlib import nrml


def number_of(elem_name, tree):
    """
    Given an element name (including the namespaces prefix, if applicable),
    return the number of occurrences of the element in a given XML document.
    """
    expr = '//%s' % elem_name
    return len(tree.xpath(expr, namespaces=nrml.PARSE_NS_MAP))


class BaseExportTestCase(unittest.TestCase):
    def _test_exported_file(self, filename):
        self.assertTrue(os.path.exists(filename))
        self.assertTrue(os.path.isabs(filename))
        self.assertTrue(os.path.getsize(filename) > 0)

## Instruction:
Fix a broken export test
## Code After:


import os
import unittest
from openquake.commonlib import nrml


def number_of(elem_name, tree):
    """
    Given an element name (including the namespaces prefix, if applicable),
    return the number of occurrences of the element in a given XML document.
    """
    expr = '//%s' % elem_name
    return len(tree.xpath(expr, namespaces={'nrml': nrml.NRML05}))


class BaseExportTestCase(unittest.TestCase):
    def _test_exported_file(self, filename):
        self.assertTrue(os.path.exists(filename))
        self.assertTrue(os.path.isabs(filename))
        self.assertTrue(os.path.getsize(filename) > 0)
