import pytest

from .common import TestCase
from h5py import File


class TestException(Exception):
    pass

def throwing(name, obj):
    print(name, obj)
    raise TestException("throwing exception")

class TestVisit(TestCase):
    def test_visit(self):
        fname = self.mktemp()
        fid = File(fname, 'w')
        fid.create_dataset('foo', (100,), dtype='uint8')
        with pytest.raises(TestException, match='throwing exception'):
            fid.visititems(throwing)
        fid.close()

import pytest

from .common import TestCase
from h5py import File


class SampleException(Exception):
    pass

def throwing(name, obj):
    print(name, obj)
    raise SampleException("throwing exception")

class TestVisit(TestCase):
    def test_visit(self):
        fname = self.mktemp()
        fid = File(fname, 'w')
        fid.create_dataset('foo', (100,), dtype='uint8')
        with pytest.raises(SampleException, match='throwing exception'):
            fid.visititems(throwing)
        fid.close()

Rename exception to squash test warning
Rename exception to squash test warning

  import pytest
  
  from .common import TestCase
  from h5py import File
  
  
- class TestException(Exception):
+ class SampleException(Exception):
      pass
  
  def throwing(name, obj):
      print(name, obj)
-     raise TestException("throwing exception")
+     raise SampleException("throwing exception")
  
  class TestVisit(TestCase):
      def test_visit(self):
          fname = self.mktemp()
          fid = File(fname, 'w')
          fid.create_dataset('foo', (100,), dtype='uint8')
-         with pytest.raises(TestException, match='throwing exception'):
+         with pytest.raises(SampleException, match='throwing exception'):
              fid.visititems(throwing)
          fid.close()
  
Rename exception to squash test warning
## Code Before:
import pytest

from .common import TestCase
from h5py import File


class TestException(Exception):
    pass

def throwing(name, obj):
    print(name, obj)
    raise TestException("throwing exception")

class TestVisit(TestCase):
    def test_visit(self):
        fname = self.mktemp()
        fid = File(fname, 'w')
        fid.create_dataset('foo', (100,), dtype='uint8')
        with pytest.raises(TestException, match='throwing exception'):
            fid.visititems(throwing)
        fid.close()

## Instruction:
Rename exception to squash test warning
## Code After:
import pytest

from .common import TestCase
from h5py import File


class SampleException(Exception):
    pass

def throwing(name, obj):
    print(name, obj)
    raise SampleException("throwing exception")

class TestVisit(TestCase):
    def test_visit(self):
        fname = self.mktemp()
        fid = File(fname, 'w')
        fid.create_dataset('foo', (100,), dtype='uint8')
        with pytest.raises(SampleException, match='throwing exception'):
            fid.visititems(throwing)
        fid.close()
