File: test__thread.py

package info (click to toggle)
python-mongomock 4.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,416 kB
  • sloc: python: 16,412; makefile: 24
file content (21 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import unittest

from mongomock.store import RWLock


class LockTestCase(unittest.TestCase):

    def test_rwlock_exception(self):
        """Asserts exceptions occur between a lock's acquire/release"""
        lock = RWLock()

        for method in [lock.reader, lock.writer]:
            try:
                with method():
                    raise ValueError
            except ValueError:
                pass

            # Accessing private attributes but oh well
            self.assertFalse(lock._no_writers.locked())
            self.assertFalse(lock._no_readers.locked())