• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hivesolutions / netius / #620889944

23 Apr 2024 08:09PM UTC coverage: 45.051%. First build
#620889944

Pull #26

travis-ci

Pull Request #26: Server support for protocols

110 of 405 new or added lines in 21 files covered. (27.16%)

7733 of 17165 relevant lines covered (45.05%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.23
/src/netius/test/base/asynchronous.py
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3

4
# Hive Netius System
5
# Copyright (c) 2008-2024 Hive Solutions Lda.
6
#
7
# This file is part of Hive Netius System.
8
#
9
# Hive Netius System is free software: you can redistribute it and/or modify
10
# it under the terms of the Apache License as published by the Apache
11
# Foundation, either version 2.0 of the License, or (at your option) any
12
# later version.
13
#
14
# Hive Netius System is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# Apache License for more details.
18
#
19
# You should have received a copy of the Apache License along with
20
# Hive Netius System. If not, see <http://www.apache.org/licenses/>.
21

22
__author__ = "João Magalhães <joamag@hive.pt>"
1✔
23
""" The author(s) of the module """
24

25
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
1✔
26
""" The copyright for the module """
27

28
__license__ = "Apache License, Version 2.0"
1✔
29
""" The license for the module """
30

31
import unittest
1✔
32

33
import netius
34

1✔
35

36
class AsynchronousTest(unittest.TestCase):
37

1✔
38
    def test_basic(self):
39
        loop = netius.get_loop(asyncio=False)
40

1✔
41
        self.assertNotEqual(loop, None)
42
        self.assertEqual(isinstance(loop, netius.Base), True)
1✔
43

44
        future = netius.build_future(compat=False, asyncio=False)
1✔
45

46
        self.assertNotEqual(future, None)
1✔
47
        self.assertEqual(isinstance(future, netius.Future), True)
1✔
48
        self.assertNotEqual(future._loop, None)
49
        self.assertEqual(isinstance(future._loop, netius.Base), True)
1✔
50

1✔
51
        previous = loop
52
        loop = netius.get_loop(_compat=True)
1✔
53

54
        self.assertNotEqual(loop, None)
1✔
55

1✔
56
        self.assertEqual(isinstance(loop, netius.BaseLoop), True)
1✔
57
        self.assertEqual(isinstance(loop, netius.CompatLoop), True)
1✔
58
        self.assertEqual(loop, previous._compat)
59
        self.assertEqual(loop._loop_ref(), previous)
1✔
60

1✔
61
        loop = netius.get_loop(asyncio=True)
62

1✔
63
        self.assertNotEqual(loop, None)
64

1✔
65
        if netius.is_asynclib():
1✔
66
            self.assertEqual(isinstance(loop, netius.BaseLoop), True)
1✔
67
            self.assertEqual(isinstance(loop, netius.CompatLoop), True)
1✔
68
        else:
69
            self.assertEqual(isinstance(loop, netius.Base), True)
1✔
70

71
    @netius.async_test
1✔
72
    def test_sleep(self):
73
        for value in netius.sleep(1.0):
1✔
74
            yield value
1✔
75
            future = value
1✔
76
        timeout = future.result()
77

×
78
        self.assertEqual(timeout, 1.0)
79
        self.assertEqual(isinstance(future, netius.Future), True)
1✔
80
        self.assertEqual(future.done(), True)
81

1✔
82

1✔
83
class FutureTest(unittest.TestCase):
1✔
84

1✔
85
    def test_is_future(self):
86
        future = netius.Future()
1✔
87

1✔
88
        result = netius.is_future(future)
1✔
89
        self.assertEqual(result, True)
90

1✔
91
    def test_is_future_native(self):
92
        try:
1✔
93
            import asyncio
1✔
94
        except:
95
            asyncio = None
1✔
96

1✔
97
        if not asyncio or not hasattr(asyncio, "isfuture"):
98
            self.skipTest("No asyncio or asyncio.isfuture() available")
1✔
99

1✔
NEW
100
        future = netius.Future()
×
101

102
        result = asyncio.isfuture(future)
1✔
NEW
103
        self.assertEqual(result, True)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc