# coding: utf-8
from __future__ import unicode_literals

from ..util import make_tempdir
from ...pipeline import NeuralDependencyParser as DependencyParser
from ...pipeline import NeuralEntityRecognizer as EntityRecognizer

import pytest


test_parsers = [DependencyParser, EntityRecognizer]


@pytest.mark.parametrize('Parser', test_parsers)
def test_serialize_parser_roundtrip_bytes(en_vocab, Parser):
    parser = Parser(en_vocab)
    parser.model, _ = parser.Model(0)
    parser_b = parser.to_bytes()
    new_parser = Parser(en_vocab)
    new_parser.model, _ = new_parser.Model(0)
    new_parser = new_parser.from_bytes(parser_b)
    assert new_parser.to_bytes() == parser_b


@pytest.mark.parametrize('Parser', test_parsers)
def test_serialize_parser_roundtrip_disk(en_vocab, Parser):
    parser = Parser(en_vocab)
    parser.model, _ = parser.Model(0)
    with make_tempdir() as d:
        file_path = d / 'parser'
        parser.to_disk(file_path)
        parser_d = Parser(en_vocab)
        parser_d.model, _ = parser_d.Model(0)
        parser_d = parser_d.from_disk(file_path)
        assert parser.to_bytes() == parser_d.to_bytes()

@@ -466,44 +466,12 @@
 del(
+1
 0)%0A
-    parser_b = parser.to_bytes()%0A
     
@@ -539,24 +539,25 @@
 arser.Model(
+1
 0)%0A    new_p
@@ -592,18 +592,27 @@
 s(parser
-_b
+.to_bytes()
 )%0A    as
@@ -647,18 +647,27 @@
 = parser
-_b
+.to_bytes()
 %0A%0A%0A@pyte
@@ -1089,32 +1089,43 @@
 parser.to_bytes(
+model=False
 ) == parser_d.to
@@ -1123,18 +1123,29 @@
 rser_d.to_bytes(
+model=False
 )%0A

Update serializer tests