<commit_before># -*- coding: utf-8 -*-
from __future__ import print_function

import re
import os
import uuid

import pytest
import popquotes.pmxbot

from pmxbot import pmxbot
from pmxbot import karma

def pytest_generate_tests(metafunc):
	# any test that takes the iter_ parameter should be executed 100 times
	if "iter_" in metafunc.funcargnames:
		for i in range(100):
			metafunc.addcall(funcargs=dict(iter_=i))

class Empty(object):
	"""
	Passed in to the individual commands instead of a client/event because
	we don't normally care about them
	"""
	pass

c = Empty()
e = Empty()


def logical_xor(a, b):
	return bool(a) ^ bool(b)

def onetrue(*args):
	truthiness = filter(bool, args)
	if len(truthiness) == 1:
		return True
	else:
		return False

class TestCommands(object):
	@classmethod
	def setup_class(self):
		path = os.path.dirname(os.path.abspath(__file__))
		configfile = os.path.join(path, 'testconf.yaml')
		pmxbot.run(configFile=configfile, start=False)
		pmxbot.botbase.logger.message("logged", "testrunner", "some text")

	@classmethod
	def teardown_class(self):
		pmxbot._cleanup()
		path = os.path.dirname(os.path.abspath(__file__))
		os.remove(os.path.join(path, 'pmxbot.sqlite'))

	@pytest.has_internet
	def test_google(self):
		"""
		Basic google search for "pmxbot". Result must contain a link.
		"""
		res = pmxbot.google(c, e, "#test", "testrunner", "pmxbot")
		print(res)
		assert "http" in res

	@pytest.has_internet
	def test_googlecalc_simple(self):
		"""
		Basic google calculator command - 1+1 must include 2 in results
		"""
		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "1+1")<commit_msg>Use new initialize func in test_commands<commit_after># -*- coding: utf-8 -*-
from __future__ import print_function

import re
import os
import uuid

import pytest
import popquotes.pmxbot

from pmxbot import pmxbot
from pmxbot import karma

def pytest_generate_tests(metafunc):
	# any test that takes the iter_ parameter should be executed 100 times
	if "iter_" in metafunc.funcargnames:
		for i in range(100):
			metafunc.addcall(funcargs=dict(iter_=i))

class Empty(object):
	"""
	Passed in to the individual commands instead of a client/event because
	we don't normally care about them
	"""
	pass

c = Empty()
e = Empty()


def logical_xor(a, b):
	return bool(a) ^ bool(b)

def onetrue(*args):
	truthiness = filter(bool, args)
	if len(truthiness) == 1:
		return True
	else:
		return False

class TestCommands(object):
	@classmethod
	def setup_class(cls):
		path = os.path.dirname(os.path.abspath(__file__))
		configfile = os.path.join(path, 'testconf.yaml')
		config = pmxbot.dictlib.ConfigDict.from_yaml(configfile)
		cls.bot = pmxbot.initialize(config)
		pmxbot.botbase.logger.message("logged", "testrunner", "some text")

	@classmethod
	def teardown_class(cls):
		pmxbot._cleanup()
		path = os.path.dirname(os.path.abspath(__file__))
		os.remove(os.path.join(path, 'pmxbot.sqlite'))

	@pytest.has_internet
	def test_google(self):
		"""
		Basic google search for "pmxbot". Result must contain a link.
		"""
		res = pmxbot.google(c, e, "#test", "testrunner", "pmxbot")
		print(res)
		assert "http" in res

	@pytest.has_internet
	def test_googlecalc_simple(self):
		"""
		Basic google calculator command - 1+1 must include 2 in results
		"""
		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "1+1")
{'fraction_non_alphanumeric': 0.12428870919436957, 'fraction_numerical': 0.007786762503743636, 'mean_word_length': 4.641891891891892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1333467', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1194, 'n_words': 322}