Skip to content

Commit df8831e

Browse files
committed
fix: modify legacy tests so that they can at least be run
even though they fail, useful for when you want to run the whole suite
1 parent 61d6385 commit df8831e

13 files changed

+52
-55
lines changed

tests/test_abnormal_crash.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from syncer import sync
99

1010
from pyppeteer import launch
11-
from pyppeteer.browser_fetcher import current_platform
1211
from pyppeteer.errors import NetworkError
1312
import pytest
1413

tests/test_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
from pyppeteer.errors import NetworkError
77

8-
from .base import BaseTestCase
8+
99
import pytest
1010

1111

12-
class TestConnection(BaseTestCase):
12+
class TestConnection:
1313
@sync
1414
async def test_error_msg(self):
1515
with pytest.raises(NetworkError, match='ThisCommand.DoesNotExists') as cm:
1616
await self.page._client.send('ThisCommand.DoesNotExists')
1717

1818

19-
class TestCDPSession(BaseTestCase):
19+
class TestCDPSession:
2020
@sync
2121
async def test_create_session(self):
2222
client = await self.page.target.createCDPSession()

tests/test_coverage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from syncer import sync
55

6-
from .base import BaseTestCase
76

87

9-
class TestJSCoverage(BaseTestCase):
8+
9+
class TestJSCoverage:
1010
@sync
1111
async def test_js_coverage(self):
1212
await self.page.coverage.startJSCoverage()
@@ -131,7 +131,7 @@ async def test_js_coverage_reset_navigation(self):
131131
assert len(coverage) == 0
132132

133133

134-
class TestCSSCoverage(BaseTestCase):
134+
class TestCSSCoverage:
135135
@sync
136136
async def test_css_coverage(self):
137137
await self.page.coverage.startCSSCoverage()

tests/test_element_handle.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import pyppeteer
1010
from pyppeteer.errors import ElementHandleError
1111

12-
from .base import BaseTestCase
13-
from .frame_utils import attachFrame
12+
13+
from .utils import attachFrame
1414
import pytest
1515

1616

17-
class TestBoundingBox(BaseTestCase):
17+
class TestBoundingBox:
1818
@sync
1919
async def test_bounding_box(self):
2020
await self.page.setViewport({'width': 500, 'height': 500})
@@ -83,7 +83,7 @@ async def test_svg(self):
8383
assert pptrBoundingBox == webBoundingBox
8484

8585

86-
class TestBoxModel(BaseTestCase):
86+
class TestBoxModel:
8787
def setUp(self):
8888
self._old_debug = pyppeteer.DEBUG
8989
super().setUp()
@@ -173,7 +173,7 @@ async def test_debug_error(self):
173173
assert await element.boxModel() is None
174174

175175

176-
class TestContentFrame(BaseTestCase):
176+
class TestContentFrame:
177177
@sync
178178
async def test_content_frame(self):
179179
await self.page.goto(self.url + 'empty')
@@ -183,7 +183,7 @@ async def test_content_frame(self):
183183
assert frame == self.page.frames[1]
184184

185185

186-
class TestClick(BaseTestCase):
186+
class TestClick:
187187
@sync
188188
async def test_clik(self):
189189
await self.page.goto(self.url + 'assets/button.html')
@@ -242,7 +242,7 @@ async def test_br_node(self):
242242
assert 'Node is either not visible or not an HTMLElement' == cm.exception.args[0]
243243

244244

245-
class TestHover(BaseTestCase):
245+
class TestHover:
246246
@sync
247247
async def test_hover(self):
248248
await self.page.goto(self.url + 'assets/scrollable.html')
@@ -251,7 +251,7 @@ async def test_hover(self):
251251
assert await self.page.evaluate('document.querySelector("button:hover").id') == 'button-6'
252252

253253

254-
class TestIsIntersectingViewport(BaseTestCase):
254+
class TestIsIntersectingViewport:
255255
@sync
256256
async def test_is_intersecting_viewport(self):
257257
await self.page.goto(self.url + 'assets/offscreenbuttons.html')
@@ -261,7 +261,7 @@ async def test_is_intersecting_viewport(self):
261261
assert await button.isIntersectingViewport() == visible
262262

263263

264-
class TestScreenshot(BaseTestCase):
264+
class TestScreenshot:
265265
@sync
266266
async def test_screenshot_larger_than_viewport(self):
267267
await self.page.setViewport({'width': 500, 'height': 500})
@@ -290,7 +290,7 @@ async def test_screenshot_larger_than_viewport(self):
290290
assert {'w': 500, 'h': 500} == size
291291

292292

293-
class TestQuerySelector(BaseTestCase):
293+
class TestQuerySelector:
294294
@sync
295295
async def test_J(self):
296296
await self.page.setContent(

tests/test_execution_context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
from pyppeteer.errors import ElementHandleError, NetworkError
77

8-
from .base import BaseTestCase
8+
99
import pytest
1010

1111

12-
class TestQueryObject(BaseTestCase):
12+
class TestQueryObject:
1313
@sync
1414
async def test_query_objects(self):
1515
await self.page.goto(self.url + 'empty')
@@ -37,7 +37,7 @@ async def test_query_objects_primitive_value_error(self):
3737
await self.page.queryObjects(prototypeHandle)
3838

3939

40-
class TestJSHandle(BaseTestCase):
40+
class TestJSHandle:
4141
@sync
4242
async def test_get_property(self):
4343
handle1 = await self.page.evaluateHandle('() => ({one: 1, two: 2, three: 3})')

tests/test_input.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
from pyppeteer.errors import PageError, PyppeteerError
1212

13-
from .base import BaseTestCase
14-
from .frame_utils import attachFrame
13+
14+
from .utils import attachFrame
1515
import pytest
1616

1717

18-
class TestClick(BaseTestCase):
18+
class TestClick:
1919
get_dimensions = '''
2020
function () {
2121
const rect = document.querySelector('textarea').getBoundingClientRect();
@@ -320,7 +320,7 @@ async def test_click_with_device_scale_factor(self):
320320
assert await frame.evaluate('result') == 'Clicked'
321321

322322

323-
class TestFileUpload(BaseTestCase):
323+
class TestFileUpload:
324324
@unittest.skipIf(
325325
sys.platform.startswith('cyg') or sys.platform.startswith('msys'), 'Hangs on cygwin/msys',
326326
)
@@ -345,7 +345,7 @@ async def test_file_upload(self):
345345
)
346346

347347

348-
class TestType(BaseTestCase):
348+
class TestType:
349349
@sync
350350
async def test_key_type(self):
351351
await self.page.goto(self.url + 'assets/textarea.html')

tests/test_launcher.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,24 @@
1717
from syncer import sync
1818
import websockets
1919

20-
from pyppeteer import connect, launch, executablePath, defaultArgs
21-
from pyppeteer.browser_fetcher import chromium_executable, current_platform
2220
from pyppeteer.errors import NetworkError
2321
from pyppeteer.launcher import launcher
2422
from pyppeteer.util import get_free_port
2523

26-
from .base import DEFAULT_OPTIONS
24+
2725
from .utils.server import get_application
2826
import pytest
2927

3028

3129
class TestLauncher(unittest.TestCase):
32-
def setUp(self):
33-
self.headless_options = [
34-
'--headless',
35-
'--hide-scrollbars',
36-
'--mute-audio',
37-
]
38-
if current_platform().startswith('win'):
39-
self.headless_options.append('--disable-gpu')
30+
# def setUp(self):
31+
# self.headless_options = [
32+
# '--headless',
33+
# '--hide-scrollbars',
34+
# '--mute-audio',
35+
# ]
36+
# if current_platform().startswith('win'):
37+
# self.headless_options.append('--disable-gpu')
4038

4139
def check_default_args(self, launcher):
4240
for opt in self.headless_options:
@@ -253,7 +251,7 @@ async def test_level_default(self):
253251
assert not self.logger.isEnabledFor(logging.DEBUG)
254252
self.mock.assert_not_called()
255253

256-
@unittest.skipIf(current_platform().startswith('win'), 'error on windows')
254+
# @unittest.skipIf(current_platform().startswith('win'), 'error on windows')
257255
@sync
258256
async def test_level_info(self):
259257
browser = await launch(args=['--no-sandbox'], logLevel=logging.INFO)
@@ -265,7 +263,7 @@ async def test_level_info(self):
265263

266264
assert 'listening on' in self.mock.call_args_list[0][0][0]
267265

268-
@unittest.skipIf(current_platform().startswith('win'), 'error on windows')
266+
# @unittest.skipIf(current_platform().startswith('win'), 'error on windows')
269267
@sync
270268
async def test_level_debug(self):
271269
browser = await launch(args=['--no-sandbox'], logLevel=logging.DEBUG)
@@ -284,7 +282,7 @@ async def test_level_debug(self):
284282
assert 'SEND' in self.mock.call_args_list[1][0][0]
285283
assert 'RECV' in self.mock.call_args_list[2][0][0]
286284

287-
@unittest.skipIf(current_platform().startswith('win'), 'error on windows')
285+
# @unittest.skipIf(current_platform().startswith('win'), 'error on windows')
288286
@sync
289287
async def test_connect_debug(self):
290288
browser = await launch(args=['--no-sandbox'])

tests/test_network.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
from pyppeteer.errors import NetworkError, PageError
1212

13-
from .base import BaseTestCase
13+
1414
import pytest
1515

1616

17-
class TestNetworkEvent(BaseTestCase):
17+
class TestNetworkEvent:
1818
@sync
1919
async def test_request(self):
2020
requests = []
@@ -35,7 +35,7 @@ async def test_request_post(self):
3535

3636
from tornado.web import RequestHandler
3737

38-
class PostHandler(RequestHandler):
38+
class PostHandler:
3939
def post(self):
4040
self.write('')
4141

@@ -150,7 +150,7 @@ async def test_not_report_body_unless_finished(self):
150150

151151
from tornado.web import RequestHandler
152152

153-
class GetHandler(RequestHandler):
153+
class GetHandler:
154154
def get(self):
155155
serverResponses.append(self)
156156
self.write('hello ')
@@ -240,7 +240,7 @@ async def test_redirects(self):
240240
assert 'redirect1' in redirectChain[0].url
241241

242242

243-
class TestRequestInterception(BaseTestCase):
243+
class TestRequestInterception:
244244
@sync
245245
async def test_request_interception(self):
246246
await self.page.setRequestInterception(True)
@@ -550,7 +550,7 @@ async def test_request_respond_bytes(self):
550550
pass
551551

552552

553-
class TestNavigationRequest(BaseTestCase):
553+
class TestNavigationRequest:
554554
@sync
555555
async def test_navigation_request(self):
556556
requests = {}

tests/test_pyppeteer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
from syncer import sync
1616

17-
from .base import BaseTestCase
1817

1918

20-
class TestPyppeteer(BaseTestCase):
19+
20+
class TestPyppeteer:
2121
@sync
2222
async def test_get_https(self):
2323
await self.page.goto('https://example.com/')
@@ -53,7 +53,7 @@ async def test_inject_file(self): # deprecated
5353
tmp_file.unlink()
5454

5555

56-
class TestScreenshot(BaseTestCase):
56+
class TestScreenshot:
5757
def setUp(self):
5858
super().setUp()
5959
self.target_path = Path(__file__).resolve().parent / 'test.png'

tests/test_screenshot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
blank_pdf_path = root_path / 'blank.pdf'
1515

1616

17-
class TestScreenShot(TestCase):
17+
class TestScreenShot:
1818
def setUp(self):
1919
self.browser = sync(launch(args=['--no-sandbox']))
2020
self.target_path = Path(__file__).resolve().parent / 'test.png'
@@ -79,7 +79,7 @@ async def test_unresolved_mimetype(self):
7979
await page.screenshot(options)
8080

8181

82-
class TestPDF(TestCase):
82+
class TestPDF:
8383
def setUp(self):
8484
self.browser = sync(launch(args=['--no-sandbox']))
8585
self.target_path = Path(__file__).resolve().parent / 'test.pdf'

0 commit comments

Comments
 (0)