mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
fix tests
This commit is contained in:
parent
e65c236dc9
commit
0961401105
8 changed files with 42 additions and 21 deletions
|
@ -716,6 +716,7 @@ class LImageItem(BoxLayout, LBase):
|
||||||
def send_event_pressed_1(self, event):
|
def send_event_pressed_1(self, event):
|
||||||
if self.group and '<1>' in self.group.bindings:
|
if self.group and '<1>' in self.group.bindings:
|
||||||
self.group.bindings['<1>'](event)
|
self.group.bindings['<1>'](event)
|
||||||
|
|
||||||
def send_event_pressed_double_1(self, event):
|
def send_event_pressed_double_1(self, event):
|
||||||
if self.group and '<Double-1>' in self.group.bindings:
|
if self.group and '<Double-1>' in self.group.bindings:
|
||||||
self.group.bindings['<Double-1>'](event)
|
self.group.bindings['<Double-1>'](event)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import time
|
|
||||||
import logging
|
import logging
|
||||||
try:
|
try:
|
||||||
import jnius
|
import jnius
|
||||||
|
@ -15,22 +14,26 @@ except ImportError:
|
||||||
# wait loop removed. (Implement it in external code if needed.)
|
# wait loop removed. (Implement it in external code if needed.)
|
||||||
# LB191011.
|
# LB191011.
|
||||||
|
|
||||||
|
|
||||||
class AndroidPerms(object):
|
class AndroidPerms(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if jnius is None:
|
if jnius is None:
|
||||||
return
|
return
|
||||||
self.PythonActivity = jnius.autoclass('org.kivy.android.PythonActivity')
|
self.PythonActivity = jnius.autoclass(
|
||||||
self.Compat = jnius.autoclass('android.support.v4.content.ContextCompat')
|
'org.kivy.android.PythonActivity')
|
||||||
self.currentActivity = jnius.cast('android.app.Activity', self.PythonActivity.mActivity)
|
self.Compat = jnius.autoclass(
|
||||||
|
'android.support.v4.content.ContextCompat')
|
||||||
|
self.currentActivity = jnius.cast(
|
||||||
|
'android.app.Activity', self.PythonActivity.mActivity)
|
||||||
|
|
||||||
def getPerm(self,permission):
|
def getPerm(self, permission):
|
||||||
if jnius is None:
|
if jnius is None:
|
||||||
return True
|
return True
|
||||||
p = self.Compat.checkSelfPermission(self.currentActivity,permission)
|
p = self.Compat.checkSelfPermission(self.currentActivity, permission)
|
||||||
return p == 0
|
return p == 0
|
||||||
|
|
||||||
# check actual permissions
|
# check actual permissions
|
||||||
def getPerms(self,permissions):
|
def getPerms(self, permissions):
|
||||||
if jnius is None:
|
if jnius is None:
|
||||||
return True
|
return True
|
||||||
haveperms = True
|
haveperms = True
|
||||||
|
@ -39,7 +42,7 @@ class AndroidPerms(object):
|
||||||
return haveperms
|
return haveperms
|
||||||
|
|
||||||
# invoke the permissions dialog
|
# invoke the permissions dialog
|
||||||
def requestPerms(self,permissions):
|
def requestPerms(self, permissions):
|
||||||
if jnius is None:
|
if jnius is None:
|
||||||
return True
|
return True
|
||||||
logging.info("androidperms: invoke permission dialog")
|
logging.info("androidperms: invoke permission dialog")
|
||||||
|
@ -52,10 +55,10 @@ def getStoragePerm():
|
||||||
return ap.getPerms(
|
return ap.getPerms(
|
||||||
["android.permission.WRITE_EXTERNAL_STORAGE"])
|
["android.permission.WRITE_EXTERNAL_STORAGE"])
|
||||||
|
|
||||||
|
|
||||||
def requestStoragePerm():
|
def requestStoragePerm():
|
||||||
ap = AndroidPerms()
|
ap = AndroidPerms()
|
||||||
#ap.requestPerms(
|
# ap.requestPerms(
|
||||||
# ["android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"])
|
# ["android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"])
|
||||||
ap.requestPerms(
|
ap.requestPerms(
|
||||||
["android.permission.WRITE_EXTERNAL_STORAGE"])
|
["android.permission.WRITE_EXTERNAL_STORAGE"])
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,11 @@ from pysollib.kivy.tkutil import after_idle
|
||||||
from pysollib.kivy.tkutil import bind
|
from pysollib.kivy.tkutil import bind
|
||||||
from pysollib.mfxutil import Struct
|
from pysollib.mfxutil import Struct
|
||||||
from pysollib.mygettext import _
|
from pysollib.mygettext import _
|
||||||
|
from pysollib.pysoltk import MfxMessageDialog
|
||||||
from pysollib.pysoltk import connect_game_find_card_dialog
|
from pysollib.pysoltk import connect_game_find_card_dialog
|
||||||
from pysollib.settings import SELECT_GAME_MENU
|
from pysollib.settings import SELECT_GAME_MENU
|
||||||
from pysollib.settings import TITLE
|
from pysollib.settings import TITLE
|
||||||
|
|
||||||
from pysollib.pysoltk import MfxMessageDialog
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * tk emuls:
|
# * tk emuls:
|
||||||
|
@ -1909,7 +1909,7 @@ class PysolMenubarTk:
|
||||||
if self._cancelDrag(break_pause=False):
|
if self._cancelDrag(break_pause=False):
|
||||||
return
|
return
|
||||||
self.app.opt.language = self.tkopt.language.get()
|
self.app.opt.language = self.tkopt.language.get()
|
||||||
d = MfxMessageDialog(
|
MfxMessageDialog(
|
||||||
self.app.top, title=_("Note"),
|
self.app.top, title=_("Note"),
|
||||||
text=_("""\
|
text=_("""\
|
||||||
These settings will take effect
|
These settings will take effect
|
||||||
|
|
|
@ -635,4 +635,3 @@ class MfxScrolledCanvas(object):
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# not used witch kivy. would not nun as it refers TkInter.
|
# not used witch kivy. would not nun as it refers TkInter.
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,11 @@ def getprefdir(package):
|
||||||
|
|
||||||
|
|
||||||
# high resolution clock() and sleep()
|
# high resolution clock() and sleep()
|
||||||
uclock = time.clock
|
try:
|
||||||
|
uclock = time.perf_counter
|
||||||
|
except Exception:
|
||||||
|
uclock = time.clock
|
||||||
|
|
||||||
usleep = time.sleep
|
usleep = time.sleep
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
uclock = time.time
|
uclock = time.time
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import gettext
|
import gettext
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
class myLocalGettext(object):
|
class myLocalGettext(object):
|
||||||
def __init__(self, lang):
|
def __init__(self, lang):
|
||||||
self.language = lang
|
self.language = lang
|
||||||
|
@ -12,7 +14,8 @@ class myLocalGettext(object):
|
||||||
if self.language == "":
|
if self.language == "":
|
||||||
t = gettext.translation(domain, localedir)
|
t = gettext.translation(domain, localedir)
|
||||||
else:
|
else:
|
||||||
t = gettext.translation(domain, localedir, languages=[self.language])
|
t = gettext.translation(
|
||||||
|
domain, localedir, languages=[self.language])
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def maketext(self, msg):
|
def maketext(self, msg):
|
||||||
|
@ -20,7 +23,7 @@ class myLocalGettext(object):
|
||||||
return six.text_type(msg, 'utf-8')
|
return six.text_type(msg, 'utf-8')
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def ungettext(self,msgid1, msgid2, n):
|
def ungettext(self, msgid1, msgid2, n):
|
||||||
# unicoded ngettext
|
# unicoded ngettext
|
||||||
msgid1 = self.maketext(msgid1)
|
msgid1 = self.maketext(msgid1)
|
||||||
msgid2 = self.maketext(msgid2)
|
msgid2 = self.maketext(msgid2)
|
||||||
|
@ -36,7 +39,7 @@ class myLocalGettext(object):
|
||||||
else:
|
else:
|
||||||
return t.ungettext(msgid1, msgid2, n)
|
return t.ungettext(msgid1, msgid2, n)
|
||||||
|
|
||||||
def ugettext(self,message):
|
def ugettext(self, message):
|
||||||
# unicoded gettext
|
# unicoded gettext
|
||||||
message = self.maketext(message)
|
message = self.maketext(message)
|
||||||
try:
|
try:
|
||||||
|
@ -48,15 +51,19 @@ class myLocalGettext(object):
|
||||||
else:
|
else:
|
||||||
return t.ugettext(message)
|
return t.ugettext(message)
|
||||||
|
|
||||||
|
|
||||||
myGettext = myLocalGettext('')
|
myGettext = myLocalGettext('')
|
||||||
|
|
||||||
|
|
||||||
def n_(x):
|
def n_(x):
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
def fix_gettext():
|
def fix_gettext():
|
||||||
gettext.ugettext = myGettext.ugettext
|
gettext.ugettext = myGettext.ugettext
|
||||||
gettext.ungettext = myGettext.ungettext
|
gettext.ungettext = myGettext.ungettext
|
||||||
|
|
||||||
|
|
||||||
fix_gettext()
|
fix_gettext()
|
||||||
|
|
||||||
_ = gettext.ugettext
|
_ = gettext.ugettext
|
||||||
|
|
|
@ -30,10 +30,10 @@ import configobj
|
||||||
import pysollib.settings
|
import pysollib.settings
|
||||||
from pysollib.mfxutil import print_err
|
from pysollib.mfxutil import print_err
|
||||||
from pysollib.mygettext import _
|
from pysollib.mygettext import _
|
||||||
|
from pysollib.mygettext import myGettext
|
||||||
from pysollib.pysoltk import TOOLBAR_BUTTONS, TOOLKIT
|
from pysollib.pysoltk import TOOLBAR_BUTTONS, TOOLKIT
|
||||||
from pysollib.resource import CSI
|
from pysollib.resource import CSI
|
||||||
|
|
||||||
from pysollib.mygettext import myGettext
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,15 @@ import re
|
||||||
from sys import platform
|
from sys import platform
|
||||||
|
|
||||||
IS_MAC = (platform == "darwin")
|
IS_MAC = (platform == "darwin")
|
||||||
PY_VERS = ([] if re.search("\\bSKIP_PY2\\b",
|
TEST_TAGS = os.getenv('TEST_TAGS', '')
|
||||||
os.getenv('TEST_TAGS', '')) else [2])+[3]
|
|
||||||
|
|
||||||
|
def _has_tag(tag):
|
||||||
|
return re.search("\\b{}\\b".format(tag), TEST_TAGS)
|
||||||
|
|
||||||
|
|
||||||
|
PY_VERS = ([] if _has_tag('SKIP_PY2') else [2])+[3]
|
||||||
|
SKIP_GTK = _has_tag('SKIP_GTK')
|
||||||
module_names = []
|
module_names = []
|
||||||
for d, _, files in os.walk("pysollib"):
|
for d, _, files in os.walk("pysollib"):
|
||||||
for f in files:
|
for f in files:
|
||||||
|
@ -23,7 +30,7 @@ for module_name in module_names:
|
||||||
continue
|
continue
|
||||||
is_gtk = ("gtk" in module_name)
|
is_gtk = ("gtk" in module_name)
|
||||||
for ver in PY_VERS:
|
for ver in PY_VERS:
|
||||||
if ((not is_gtk) or (ver == 2 and (not IS_MAC))):
|
if ((not is_gtk) or (ver == 2 and (not IS_MAC) and (not SKIP_GTK))):
|
||||||
def fmt(s):
|
def fmt(s):
|
||||||
return s % {'module_name': module_name, 'ver': ver}
|
return s % {'module_name': module_name, 'ver': ver}
|
||||||
open(os.path.join(".", "tests", "individually-importing", fmt("import_v%(ver)d_%(module_name)s.py")), 'w').write(fmt('''#!/usr/bin/env python%(ver)d
|
open(os.path.join(".", "tests", "individually-importing", fmt("import_v%(ver)d_%(module_name)s.py")), 'w').write(fmt('''#!/usr/bin/env python%(ver)d
|
||||||
|
|
Loading…
Add table
Reference in a new issue