-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhishek's Macbook Pro
authored and
Abhishek's Macbook Pro
committed
Sep 30, 2023
1 parent
4269aa2
commit 67294d8
Showing
16 changed files
with
319 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run-tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
st-version: [3, 4] | ||
os: ["ubuntu-latest", "macOS-latest", "windows-latest"] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: SublimeText/UnitTesting/actions/setup@v1 | ||
with: | ||
sublime-text-version: ${{ matrix.st-version }} | ||
- uses: SublimeText/UnitTesting/actions/run-tests@v1 | ||
with: | ||
coverage: true | ||
codecov-upload: true | ||
|
||
run-syntax-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: SublimeText/UnitTesting/actions/setup@v1 | ||
- uses: SublimeText/UnitTesting/actions/run-syntax-tests@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,4 +162,6 @@ cython_debug/ | |
~/ | ||
exp.py | ||
exp.sh | ||
exp2.py | ||
exp2.py | ||
pyrock.sublime-project | ||
pyrock.sublime-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import importlib | ||
import os | ||
from types import ModuleType | ||
from typing import Optional | ||
|
||
def import_sub_module(module_path) -> Optional[ModuleType]: | ||
""" | ||
:module_path -> In form of "Plugin.foo.bar" | ||
""" | ||
try: | ||
print(f"Reloading: {module_path}") | ||
return importlib.import_module(module_path) | ||
except ModuleNotFoundError: | ||
print(f"Unable to import {module_path}") | ||
return None | ||
|
||
def walk_sub_modules(plugin_name, base_path): | ||
for dir, _, files in os.walk(base_path): | ||
parent_module_imported = False | ||
# If its a root directory | ||
if plugin_name == os.path.basename(dir): | ||
parent_module_path = plugin_name | ||
else: | ||
# This gives result as Plugin.foo.bar | ||
parent_module_path = f"{plugin_name}{'.'.join(str(dir).split(plugin_name)[-1].split(os.path.sep))}" | ||
for file in files: | ||
file_name, extension = os.path.splitext(file) | ||
if extension == '.py': | ||
# Importing once only | ||
if not parent_module_imported: | ||
# Only trying to import parent once we know it has .py file | ||
import_sub_module(parent_module_path) | ||
parent_module_imported = True | ||
# Importing .py file | ||
import_sub_module(f"{parent_module_path}.{file_name}") | ||
|
||
def reload(): | ||
plugin = importlib.import_module("PyRock") | ||
walk_sub_modules("PyRock", plugin.__path__[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sublime | ||
from unittesting import DeferrableTestCase | ||
|
||
|
||
class PyRockTestBase(DeferrableTestCase): | ||
def setUp(self): | ||
self.view = sublime.active_window().new_file( | ||
syntax='Packages/Python/Python.sublime-syntax' | ||
) | ||
self.window = self.view.window() | ||
self.sublime_settings = sublime.load_settings("Preferences.sublime-settings") | ||
self.sublime_settings.set("close_windows_when_empty", False) | ||
|
||
def tearDown(self): | ||
if self.view: | ||
self.view.set_scratch(True) | ||
self.view.window().focus_view(self.view) | ||
self.view.window().run_command("close_file") | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sublime | ||
from unittest import mock | ||
from tests.base import PyRockTestBase | ||
from PyRock.src.commands.base_indexer import BaseIndexer | ||
|
||
|
||
class TestIndexer(PyRockTestBase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
@mock.patch("PyRock.src.commands.base_indexer.BaseIndexer._run_import_indexer") | ||
def test_run_indexer( | ||
self, | ||
mocked_run_import_indexer, | ||
): | ||
mocked_run_import_indexer.return_value = (True, "") | ||
|
||
base_indexer = BaseIndexer() | ||
base_indexer._run_indexer(self.window, True) | ||
|
||
import_command = base_indexer._get_import_command() | ||
|
||
mocked_run_import_indexer.assert_called_once_with(self.window, import_command) |
Oops, something went wrong.