Compare commits
8 Commits
master
...
python_tes
Author | SHA1 | Date |
---|---|---|
skullY | 41e8b4159a | 6 years ago |
skullY | 23f48491ef | 6 years ago |
skullY | 269cba6aa7 | 6 years ago |
skullY | 1a8878c174 | 6 years ago |
skullY | 788bd8978d | 6 years ago |
skullY | b70c2e848d | 6 years ago |
skullY | eb57023bde | 6 years ago |
skullY | 926c87c0e2 | 6 years ago |
@ -0,0 +1,23 @@
|
||||
/* Copyright 2019
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#define MATRIX_COL_PINS { A3 }
|
||||
#define MATRIX_ROW_PINS { A2 }
|
||||
#define UNUSED_PINS
|
@ -0,0 +1,3 @@
|
||||
# PyTest onekey
|
||||
|
||||
This is used by the python test framework. It's probably not useful otherwise.
|
@ -0,0 +1,2 @@
|
||||
# MCU name
|
||||
MCU = STM32F303
|
@ -0,0 +1 @@
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};
|
@ -0,0 +1,18 @@
|
||||
"""QMK Python Unit Tests
|
||||
|
||||
QMK script to run unit and integration tests against our python code.
|
||||
"""
|
||||
from milc import cli
|
||||
|
||||
|
||||
@cli.entrypoint('QMK Python Unit Tests')
|
||||
def main(cli):
|
||||
"""Use nose2 to run unittests
|
||||
"""
|
||||
try:
|
||||
import nose2
|
||||
except ImportError:
|
||||
cli.log.error('Could not import nose2! Please install it with {fg_cyan}pip3 install nose2')
|
||||
return False
|
||||
|
||||
nose2.discover()
|
@ -0,0 +1,16 @@
|
||||
"""Format python code according to QMK's style.
|
||||
"""
|
||||
from milc import cli
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
@cli.entrypoint("Format python code according to QMK's style.")
|
||||
def main(cli):
|
||||
"""Format python code according to QMK's style.
|
||||
"""
|
||||
try:
|
||||
subprocess.run(['yapf', '-vv', '-ri', 'bin/qmk', 'lib/python'], check=True)
|
||||
cli.log.info('Successfully formatted the python code in `bin/qmk` and `lib/python`.')
|
||||
except subprocess.CalledProcessError:
|
||||
cli.log.error('Error formatting python code!')
|
@ -0,0 +1,9 @@
|
||||
class AttrDict(dict):
|
||||
"""A dictionary that can be accessed by attributes.
|
||||
|
||||
This should only be used to mock objects for unit testing. Please do not use this outside of qmk.tests.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AttrDict, self).__init__(*args, **kwargs)
|
||||
self.__dict__ = self
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"keyboard":"handwired/onekey/pytest",
|
||||
"keymap":"pytest_unittest",
|
||||
"layout":"LAYOUT",
|
||||
"layers":[["KC_A"]]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
from qmk.errors import NoSuchKeyboardError
|
||||
|
||||
|
||||
def test_NoSuchKeyboardError():
|
||||
try:
|
||||
raise NoSuchKeyboardError("test message")
|
||||
except NoSuchKeyboardError as e:
|
||||
assert e.message == 'test message'
|
@ -0,0 +1,19 @@
|
||||
import qmk.keymap
|
||||
|
||||
|
||||
def test_template_onekey_proton_c():
|
||||
templ = qmk.keymap.template('handwired/onekey/proton_c')
|
||||
assert templ == qmk.keymap.DEFAULT_KEYMAP_C
|
||||
|
||||
|
||||
def test_template_onekey_pytest():
|
||||
templ = qmk.keymap.template('handwired/onekey/pytest')
|
||||
assert templ == 'const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n'
|
||||
|
||||
|
||||
def test_generate_onekey_pytest():
|
||||
templ = qmk.keymap.generate('handwired/onekey/pytest', 'LAYOUT', [['KC_A']])
|
||||
assert templ == 'const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT(KC_A)};\n'
|
||||
|
||||
|
||||
# FIXME(skullydazed): Add a test for qmk.keymap.write that mocks up an FD.
|
@ -0,0 +1,13 @@
|
||||
import os
|
||||
|
||||
import qmk.path
|
||||
|
||||
|
||||
def test_keymap_onekey_pytest():
|
||||
path = qmk.path.keymap('handwired/onekey/pytest')
|
||||
assert path == 'keyboards/handwired/onekey/keymaps'
|
||||
|
||||
|
||||
def test_normpath():
|
||||
path = qmk.path.normpath('lib/python')
|
||||
assert path == os.environ['ORIG_CWD'] + '/lib/python'
|
Loading…
Reference in new issue