<commit_before># -*- coding: utf-8 -*-
"""Tests for google3.third_party.car.hw.testing.output.email."""

import json
import logging
import os
import unittest

from openhtf.core import measurements
from openhtf.core import test_record
from openhtf.util import logs as test_logs
from openhtf.util import units

import openhtf as htf
from openhtf import util
from examples import all_the_things
from openhtf.output.callbacks import console_summary
from openhtf.output.callbacks import json_factory
from openhtf.output.proto import assembly_event_pb2
from openhtf.output.proto import mfg_event_converter
from openhtf.output.proto import mfg_event_pb2
from openhtf.output.proto import test_runs_converter
from openhtf.output.proto import test_runs_pb2


TEST_MULTIDIM_JSON_FILE = os.path.join(os.path.dirname(__file__),
    'multidim_testdata.json')
with open(TEST_MULTIDIM_JSON_FILE, 'r') as f:
  TEST_MULTIDIM_JSON = f.read()

class MfgEventConverterTest(unittest.TestCase):

  def create_codeinfo(self):
    return test_record.CodeInfo(
        name='mock-codeinfo-name',
        docstring='mock-docstring',
        sourcecode='mock-sourcecode',
    )

  def test_mfg_event_from_test_record(self):
    """Test for the full conversion flow."""
    record = test_record.TestRecord(
        dut_id='dut_serial',
        start_time_millis=1,
        end_time_millis=1,
        station_id='localhost',
        outcome=test_record.Outcome.PASS,
    )<commit_msg>Using io.open instead of built-in open for unit test. (#857)<commit_after># -*- coding: utf-8 -*-
"""Tests for google3.third_party.car.hw.testing.output.email."""

import io
import json
import logging
import os
import unittest

from openhtf.core import measurements
from openhtf.core import test_record
from openhtf.util import logs as test_logs
from openhtf.util import units

import openhtf as htf
from openhtf import util
from examples import all_the_things
from openhtf.output.callbacks import console_summary
from openhtf.output.callbacks import json_factory
from openhtf.output.proto import assembly_event_pb2
from openhtf.output.proto import mfg_event_converter
from openhtf.output.proto import mfg_event_pb2
from openhtf.output.proto import test_runs_converter
from openhtf.output.proto import test_runs_pb2


TEST_MULTIDIM_JSON_FILE = os.path.join(
    os.path.dirname(__file__),
    'multidim_testdata.json')
with io.open(TEST_MULTIDIM_JSON_FILE, 'r', encoding='utf-8') as f:
  TEST_MULTIDIM_JSON = f.read()

class MfgEventConverterTest(unittest.TestCase):

  def create_codeinfo(self):
    return test_record.CodeInfo(
        name='mock-codeinfo-name',
        docstring='mock-docstring',
        sourcecode='mock-sourcecode',
    )

  def test_mfg_event_from_test_record(self):
    """Test for the full conversion flow."""
    record = test_record.TestRecord(
        dut_id='dut_serial',
        start_time_millis=1,
        end_time_millis=1,
        station_id='localhost',
        outcome=test_record.Outcome.PASS,
    )
{'fraction_non_alphanumeric': 0.08559010364426613, 'fraction_numerical': 0.006018054162487462, 'mean_word_length': 4.510128913443831, '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': '5444764', 'n_tokens_mistral': 983, 'n_tokens_neox': 967, 'n_words': 225}