U
    kuf	                     @   s   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	ZG dd de
Zdejkrreejd d Zneejjjd	 Ze se eed
 Zejddd edD dd ZdS )    )PathN)Registry)Unresolvablec                   @   s   e Zd Zdd ZdS )SuiteNotFoundc                 C   s   dS )NzCannot find the referencing suite. Set the REFERENCING_SUITE environment variable to the path to the suite, or run the test suite from alongside a full checkout of the git repository. )selfr   r   L/tmp/pip-unpacked-wheel-g5oy8ly_/referencing/tests/test_referencing_suite.py__str__   s    zSuiteNotFound.__str__N)__name__
__module____qualname__r	   r   r   r   r   r      s   r   ZREFERENCING_SUITEtestszsuite/testszspecifications.json	test_pathc                 C   s*   g | ]"}t j||jj d |j dqS )-)id)pytestparamparentnamestem).0Zeachr   r   r   
<listcomp>!   s   r   z*/**/*.jsonc           	         sT  t | tjd  }tj| t| 	 }|d }t
  fdd|d  D }|d D ]}|j|d d| jkrtd |j|d	d
d}|drtt ||d  W 5 Q R X nz||d }|j|d kst|d}|rD|j||d* |j|d }|j|d ks.tW 5 Q R X |d}qW 5 Q R X q`d S )Nr   registryc                 3   s    | ]\}}|  |fV  qd S )N)Zcreate_resource)r   uricontentsspecificationr   r   	<genexpr>+   s   z)test_referencing_suite.<locals>.<genexpr>r   )testZnormalizationz+APIs need to change for proper URL support.base_uri )r   errorreftargetthen)r   r$   )DIALECT_IDSrelative_toSUITEpartsreferencingZ
jsonschemaZspecification_withjsonloads	read_textr   Zwith_resourcesitemsr   r   r   ZxfailresolvergetZraisesr   lookupr   AssertionError)	r   ZsubtestsZ
dialect_idZloadedr   r   r.   Zresolvedr$   r   r   r   test_referencing_suite   s.    




r2   )pathlibr   r*   osr   r)   r   Zreferencing.exceptionsr   Zreferencing.jsonschema	Exceptionr   environr'   __file__r   is_dirr+   joinpathr,   r%   markZparametrizeglobr2   r   r   r   r   <module>   s(   

