File: test_context_manager.py

package info (click to toggle)
python-secretstorage 3.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: python: 697; makefile: 11; sh: 8
file content (24 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Tests for SecretStorage
# Author: Dmitry Shachnev, 2019
# License: 3-clause BSD, see LICENSE file

# This file tests using secretstorage.dbus_init() function
# together with contextlib.closing context manager.

from contextlib import closing
import unittest
from secretstorage import check_service_availability, dbus_init
from secretstorage.collection import get_any_collection


class ContextManagerTest(unittest.TestCase):
    """``dbus_init()`` should work fine with ``contextlib.closing``
    context manager."""

    def test_closing_context_manager(self) -> None:
        with closing(dbus_init()) as connection:
            self.assertTrue(check_service_availability(connection))
            collection = get_any_collection(connection)
            self.assertIsNotNone(collection)
            label = collection.get_label()
            self.assertIsNotNone(label)