Move ignore SIGCHLD to entry points.

Ignoring SIGCHLD trips up unittests, this was done as the unittest loaded mycroft.skills.core
pull/754/head
Åke Forslund 2017-04-15 11:50:36 +02:00 committed by Augusto Monteiro 'Sparky
parent e21acc2d12
commit 484d4a9ce3
5 changed files with 12 additions and 202 deletions

View File

@ -25,6 +25,10 @@ from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.skills.core import create_skill_descriptor, load_skill
from mycroft.skills.intent_service import IntentService
from mycroft.util.log import getLogger
import signal
# ignore DIGCHLD to terminate subprocesses correctly
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
__author__ = 'seanfitz'

View File

@ -18,6 +18,8 @@
import abc
import imp
import time
import os.path
import re
import signal
@ -35,8 +37,6 @@ from mycroft.util.log import getLogger
__author__ = 'seanfitz'
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
BLACKLISTED_SKILLS = ["send_sms", "media"]
SKILLS_DIR = "/opt/mycroft/skills"

View File

@ -33,6 +33,12 @@ from mycroft.skills.core import load_skill, create_skill_descriptor, \
from mycroft.skills.intent_service import IntentService
from mycroft.util.log import getLogger
from mycroft.lock import Lock # Creates PID file for single instance
import signal
# ignore DIGCHLD to terminate subprocesses correctly
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
logger = getLogger("Skills")
__author__ = 'seanfitz'

View File

@ -1,100 +0,0 @@
import unittest
import wolframalpha
from StringIO import StringIO
from mycroft.skills.wolfram_alpha import WolframAlphaSkill
from mycroft.util.log import getLogger
__author__ = 'eward'
logger = getLogger(__name__)
class WolframAlphaTest(unittest.TestCase):
skill = WolframAlphaSkill()
@staticmethod
def format_result(pod_id, text, pod_num):
return "<queryresult>\
<pod id='" + pod_id + "' title = '" + pod_id + \
"' position='" + pod_num + "'><subpod> \
<plaintext>" + text + "</plaintext></subpod></pod></queryresult>"
@staticmethod
def format_did_you_mean(text):
tree = "<queryresult><didyoumeans>"
for result in text:
tree += "<didyoumean>" + result + "</didyoumean>"
tree += "</didyoumeans></queryresult>"
return tree
def create_result(self, pod_id, value, pod_num):
result = self.format_result(pod_id, value, pod_num)
return wolframalpha.Result(StringIO(result))
def create_did_you_mean(self, text):
test = self.format_did_you_mean(text)
return wolframalpha.Result(StringIO(test))
def test_result_pod(self):
res = self.create_result("Result", "7", '300')
self.assertEquals(self.skill.get_result(res), "7")
def test_value_pod(self):
res = self.create_result("Value", "2^3", '300')
self.assertEquals(self.skill.get_result(res), "2^3")
def test_notable_facts_pod(self):
res = self.create_result("NotableFacts:PeopleData",
"PeopleData", '300')
self.assertEquals(self.skill.get_result(res), "PeopleData")
def test_basic_information_pod(self):
res = self.create_result("BasicInformation:PeopleData",
"Born in 1997", '300')
self.assertEquals(self.skill.get_result(res), "Born in 1997")
def test_decimal_approximation_pod(self):
res = self.create_result("DecimalApproximation", "5.6666666666", '300')
self.assertEquals(self.skill.get_result(res), "5.666")
def test_definition_pod(self):
res = self.create_result("Definition:WordData",
"a cat is a feline", '300')
self.assertEquals(self.skill.get_result(res),
"a cat is a feline")
def test_numbered_pod(self):
res = self.create_result("MathConcept", "tangrams are objects", '200')
self.assertEqual(self.skill.get_result(res),
"tangrams are objects")
def test_invalid_pod(self):
res = self.create_result("InvalidTitle", "Test", '300')
self.assertEquals(self.skill.get_result(res), None)
def test_whitespace_process(self):
self.assertEquals(self.skill.process_wolfram_string
("Test string"), "Test string")
def test_pipe_process(self):
self.assertEquals(self.skill.process_wolfram_string
("Test | string"), "Test, string")
def test_newline_process(self):
self.assertEquals(self.skill.process_wolfram_string
("Test\nstring"), "Test, string")
def test_factorial_process(self):
self.assertEquals(self.skill.process_wolfram_string
("Test!"), "Test,factorial")
def test_find_did_you_mean_exists(self):
values = ['search for power', 'power']
res = self.create_did_you_mean(values)
self.assertEquals(self.skill._find_did_you_mean(res),
values)
def test_find_did_you_mean_none(self):
res = self.create_did_you_mean([])
self.assertEquals(self.skill._find_did_you_mean(res), [])

View File

@ -1,100 +0,0 @@
import unittest
from mycroft.skills.wolfram_alpha import EnglishQuestionParser
__author__ = 'wolfgange3311999'
class EnglishQuestionParserTest(unittest.TestCase):
parser = EnglishQuestionParser()
test_jsons = [
{
'utterance': 'who is abraham lincoln',
'parsed_question': {
'QuestionWord': 'who',
'QuestionVerb': 'is',
'Query': 'abraham lincoln'
}
},
{
'utterance': 'what are they',
'parsed_question': {
'QuestionWord': 'what',
'QuestionVerb': 'are',
'Query': 'they'
}
},
{
'utterance': 'when was this',
'parsed_question': {
'QuestionWord': 'when',
'QuestionVerb': 'was',
'Query': 'this'
}
},
{
'utterance': 'why were they there',
'parsed_question': {
'QuestionWord': 'why',
'QuestionVerb': 'were',
'Query': 'they there'
}
},
{
'utterance': 'which is the thing',
'parsed_question': {
'QuestionWord': 'which',
'QuestionVerb': 'is',
'Query': 'the thing'
}
},
{
'utterance': 'who saw abraham lincoln',
'parsed_question': {
'QuestionWord': 'who',
'QuestionVerb': 'saw',
'Query': 'abraham lincoln'
}
},
{
'utterance': 'what began life',
'parsed_question': {
'QuestionWord': 'what',
'QuestionVerb': 'began',
'Query': 'life'
}
},
{
'utterance': 'where sat the person',
'parsed_question': {
'QuestionWord': 'where',
'QuestionVerb': 'sat',
'Query': 'the person'
}
},
{
'utterance': 'i like stuff',
'parsed_question': None
},
{
'utterance': 'what\'s a dog',
'parsed_question': {
'QuestionWord': 'what',
'QuestionVerb': '\'s',
'Query': 'a dog'
}
},
{
'utterance': 'who did this',
'parsed_question': {
'QuestionWord': 'who',
'QuestionVerb': 'did',
'Query': 'this'
}
}
]
def test_question_parsing(self):
for test_json in self.test_jsons:
parsed_question = self.parser.parse(test_json['utterance'])
self.assertEquals(parsed_question, test_json['parsed_question'])