Skip to content

Commit

Permalink
gh #356 codecov opera.py (#358)
Browse files Browse the repository at this point in the history
- optimize if/else in opera.py::OperaDriverManager::install()
also:
- move code from tests/utils.py to test_downloader.py
- remove 3.13.0, 3.141.59 from test_ie_driver.py as unnecessary
- add project's .gitignore
  • Loading branch information
aleksandr-kotlyar authored Mar 24, 2022
1 parent 305ae84 commit 259cfdb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Project
ssl_disabled/
custom/
.venv*/
venv*/
drivers/
drivers.json

# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
Expand Down
6 changes: 4 additions & 2 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

import pytest

from tests.utils import driver_directory
from webdriver_manager.driver import ChromeDriver
from webdriver_manager.utils import download_file, save_file, ChromeType

project_root = os.path.dirname(os.path.dirname(__file__))

driver_directory = f"{project_root}{os.sep}.drivers"


@pytest.fixture()
def delete_drivers_dir():
Expand Down Expand Up @@ -42,4 +45,3 @@ def test_can_download_chrome_driver(delete_drivers_dir, version):
assert file.filename == "driver.zip"
archive = save_file(file, driver_directory)
assert archive.unpack(driver_directory) == ["chromedriver.exe"]

3 changes: 0 additions & 3 deletions tests/test_ie_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@


@pytest.mark.parametrize("version", [
"2.53.1",
"3.0",
"3.13.0",
"3.141.59",
"3.150.0",
# "3.150.1",
# "3.150.2",
Expand Down
5 changes: 0 additions & 5 deletions tests/utils.py

This file was deleted.

11 changes: 4 additions & 7 deletions webdriver_manager/opera.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ def __init__(self, version="latest",

def install(self):
driver_path = self._get_driver_path(self.driver)
if os.path.isfile(driver_path):
os.chmod(driver_path, 0o755)
return driver_path
else:
if not os.path.isfile(driver_path):
for name in os.listdir(driver_path):
if 'sha512_sum' in name:
os.remove(os.path.join(driver_path, name))
break
file_path = os.path.join(driver_path, os.listdir(driver_path)[0])
os.chmod(file_path, 0o755)
return file_path
driver_path = os.path.join(driver_path, os.listdir(driver_path)[0])
os.chmod(driver_path, 0o755)
return driver_path

0 comments on commit 259cfdb

Please sign in to comment.