<commit_before>import pyprika
import yaml, json, simplejson
from pyprika import Recipe, ParseError, Ingredient, loads, dumps, LoadError
from .common import BaseTest

STANDARD_DICT = {
  'name': 'My Special Recipe',
  'prep_time': '1 day',
  'cook_time': '1 week',
  'servings': [2, 4],
  'source': 'Source Person',
  'source_url': 'http://example.com/',
  'notes': 'some notes',
  'ingredients': [
    '(1.5 cup) milk',
    '(1 1/2 cup) milk',
    '(1 cup) milk',
    '(1) egg',
    'salt',
  ],
  'directions': [
    'Put it in a bowl',
    'Mix \'em up.',
  ],
}

class StaticTest(BaseTest):
  def test_empty(self):
    d = {}
    self.assertRaises(KeyError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_key(self): 
    d = {'name': 'Recipe', 'x': 3}
    self.assertRaises(AttributeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_syntax_1(self):
    d = {'name': 'Recipe', 'prep_time': '1.1.1 days'}
    self.assertRaises(ParseError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_1(self):
    d = {'name': 'Recipe', 'servings': 'four'}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_2(self):
    d = {'name': 'Recipe', 'servings': (1,)}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_3(self):
    d = {'name': 'Recipe', 'servings': (1,2,3)}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

class InstanceTest(BaseTest):
  pass

class ManualInstanceTest(InstanceTest):
  @classmethod
  def setUpClass(cls):
    i = cls.instance = Recipe.from_dict(STANDARD_DICT)

class BasicTest(object):

  def test_copy(self):
    from copy import deepcopy
    i = self.instance
    result = deepcopy(i)
    print i.to_dict()
    print result.to_dict()
    self.assertEqual(i, result)

  def test_mul(self):
    i = self.instance
    result = i * 2
    result = result * 0.5<commit_msg>remove prints from test case<commit_after>import pyprika
import yaml, json, simplejson
from pyprika import Recipe, ParseError, Ingredient, loads, dumps, LoadError
from .common import BaseTest

STANDARD_DICT = {
  'name': 'My Special Recipe',
  'prep_time': '1 day',
  'cook_time': '1 week',
  'servings': [2, 4],
  'source': 'Source Person',
  'source_url': 'http://example.com/',
  'notes': 'some notes',
  'ingredients': [
    '(1.5 cup) milk',
    '(1 1/2 cup) milk',
    '(1 cup) milk',
    '(1) egg',
    'salt',
  ],
  'directions': [
    'Put it in a bowl',
    'Mix \'em up.',
  ],
}

class StaticTest(BaseTest):
  def test_empty(self):
    d = {}
    self.assertRaises(KeyError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_key(self): 
    d = {'name': 'Recipe', 'x': 3}
    self.assertRaises(AttributeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_syntax_1(self):
    d = {'name': 'Recipe', 'prep_time': '1.1.1 days'}
    self.assertRaises(ParseError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_1(self):
    d = {'name': 'Recipe', 'servings': 'four'}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_2(self):
    d = {'name': 'Recipe', 'servings': (1,)}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

  def test_invalid_type_3(self):
    d = {'name': 'Recipe', 'servings': (1,2,3)}
    self.assertRaises(TypeError, Recipe.from_dict, d)
    self.assertRaises(LoadError, loads, yaml.dump(d))

class InstanceTest(BaseTest):
  pass

class ManualInstanceTest(InstanceTest):
  @classmethod
  def setUpClass(cls):
    i = cls.instance = Recipe.from_dict(STANDARD_DICT)

class BasicTest(object):

  def test_copy(self):
    from copy import deepcopy
    i = self.instance
    result = deepcopy(i)
    self.assertEqual(i, result)

  def test_mul(self):
    i = self.instance
    result = i * 2
    result = result * 0.5
{'fraction_non_alphanumeric': 0.15524475524475526, 'fraction_numerical': 0.012121212121212121, 'mean_word_length': 3.904, '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': '6577199', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1572, 'n_words': 359}