File tree Expand file tree Collapse file tree 4 files changed +64
-7
lines changed
Expand file tree Collapse file tree 4 files changed +64
-7
lines changed Original file line number Diff line number Diff line change 11# This workflow will install Python dependencies, run tests and lint with a single version of Python
22# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33
4- name : Python application
4+ name : Build
55
66on :
77 push :
8- branches : [ master ]
8+ branches : [ release ]
99 pull_request :
10- branches : [ master ]
10+ branches : [ release ]
1111
1212jobs :
1313 build :
@@ -24,10 +24,16 @@ jobs:
2424 run : |
2525 python -m pip install --upgrade pip
2626 pip install -r requirements.txt
27+ - name : Setup Chromedriver
28+ uses : nanasess/setup-chromedriver@v1.0.1
2729 - name : Lint with flake8
2830 run : |
2931 pip install flake8
3032 # stop the build if there are Python syntax errors or undefined names
3133 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3234 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3335 flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+ - name : Test with pytest
37+ run : |
38+ pip install pytest
39+ pytest
Original file line number Diff line number Diff line change 1- # BOJ source saver
1+ # BOJ source downloader
22
3- ![ Python application ] ( https://github.com/joonas-yoon/boj-source-saver/workflows/Python%20application /badge.svg )
3+ ![ build ] ( https://github.com/joonas-yoon/boj-source-saver/workflows/Build /badge.svg )
44
5- Save your ACCEPTED codes on [ BOJ] ( https://www.acmicpc.net )
5+ Download your ACCEPTED codes on [ BOJ] ( https://www.acmicpc.net )
66
77## Requirements
88
@@ -12,7 +12,7 @@ Save your ACCEPTED codes on [BOJ](https://www.acmicpc.net)
1212
1313### Chrome WebDriver
1414
15- Download ` chromedriver.exe ` from https://sites.google.com/a/chromium.org/chromedriver/downloads
15+ Prepare and download ` chromedriver.exe ` from https://sites.google.com/a/chromium.org/chromedriver/downloads
1616
1717and place it in project directory.
1818
Original file line number Diff line number Diff line change 1+ import os
2+ from selenium import webdriver
3+ from util import Chrome , APP_DIR
4+
5+
6+ def test_chrome ():
7+ chrome_driver = os .path .join (APP_DIR , 'chromedriver' )
8+
9+ chrome_options = webdriver .ChromeOptions ()
10+ chrome_options .add_argument ('--headless' )
11+ chrome_options .add_argument ('--no-sandbox' )
12+ chrome_options .add_argument ('--disable-dev-shm-usage' )
13+ chrome_options .add_argument ('--disable-gpu' )
14+
15+ driver = webdriver .Chrome (chrome_driver , options = chrome_options )
16+ driver .implicitly_wait (3 )
17+ assert driver is not None
18+
19+ driver .quit ()
20+
21+
22+ def test_chrome_util ():
23+ chrome = Chrome (headless = True )
24+ driver = chrome .get_driver ()
25+ assert driver is not None
26+ driver .quit ()
Original file line number Diff line number Diff line change 1+ from bs4 import BeautifulSoup
2+ from util import Chrome
3+
4+
5+ def get_driver ():
6+ driver = Chrome (headless = True ).get_driver ()
7+ driver .implicitly_wait (3 )
8+ return driver
9+
10+
11+ def connect (driver ):
12+ driver .get ('https://github.com/' )
13+ return driver
14+
15+
16+ # for pytest
17+ def test_main ():
18+ driver = get_driver ()
19+ assert driver is not None
20+
21+ html = connect (driver ).page_source
22+ soup = BeautifulSoup (html , 'html.parser' )
23+ assert soup is not None
24+
25+ driver .quit ()
You can’t perform that action at this time.
0 commit comments